I like that alot! I always like the procedural media, and that one is very sweet! Do you have any others that we could use? That one will do the direction fine, I imagine. It will be pretty easy to hook up to the data, I think. (Getting, then getting to the data will be the rough slog.)
I am not sure, but that might not be the maximum speed possible, I still haven't looked at the data sheets yet. I have them, and here are the links to the pdfs, if you do not already have them:
http://datasheets.maxim-ic.com/en/ds/DS2450.pdf
http://datasheets.maxim-ic.com/en/ds/DS1920.pdf
http://datasheets.maxim-ic.com/en/ds/DS2423.pdf
I did not get much time in on this tonight, but I was able to begin to make a layer of abstraction so that we can use the devices in your application more easily. I am nearly there. Soon, things will get a little dodgy, but we will muddle through.
I disagree with the contention that DBPro cannot be used in an OO manner. I suppose that I will settle on calling this method object centric as opposed to object-oriented. Anyway, it is applicable to more than just iButtons; it works well in a game loop, too.
[REFERENCE: lines 1257-1446]
I apologize for the display, I keep avoiding taking absolute control over the display. It will happen soon, though. It is a real mess now, but it is nice to have all of that info a function call away, isn't it?
WRT the size of the code, I would not be offended if asked to cease posting it. It looks alot better now than it did before anyway.
REM Project: iButton
REM Created: 11/10/2006 11:34:11 PM
REM jinzai Silvis, IL USA
REM ***** Main Source File *****
REM 1-Wire Network Communications
remstart This represents a complete DBPro interface to the TMEX API provided
by Dallas Semiconductor for use of their 1-Wire Network and iButton
devices. As of 11/13/2006, the entire API can be called. From now on,
I will place changes here in chronological order, leading up to a
version 1.0.0, which I will place in the code base, perhaps with
some more information and sources for iButtons. I got onboard for
less than $50USD, and it looks very interesting to me, with some
potential game and game development uses. Stay tuned.
mtb11.13.2006
remend
remstart I have added the underpinnings of support for an additional layer
of abstraction tonight, and also I have done a little tidying up,
eliminating some unused variables, and also making some structures
more specific. Notice the GetDevice functions. There will be more
of those to come. Also, I have begun to expand the error checking.
I will have full error reporting and also some error correcting
later in the week. Then the entire connection will be more
automatic, and easier to establish and maintain for the less savvy
user. I might even add some troubleshooting help.
mtb11.14.2006
remend
remstart I added a NETCONNECTION type, and put almost all of the globals
in it that are needed for a managed connection. I have exposed the
connection through the global NETCONNECTION UDT, this. There are
global functions to access almost all of the network connectivity.
I have also cleaned the code up some more, and am keeping all returns
by layer API in the this object. I continued to try to abstract the
connection from the application layer somewhat. You can still
manipulate it as before, but now it is accessed through the this
object. Next, I will add more error reporting options, and add more
functions for Devices and this.
mtb11.15.2006
remend
rem Define some UDTs.
rem I am smuggling this array into the specification type below. Now, when
rem it comes out, it will look almost like a class. It is tantamount to a base
rem class of type Device. The global functions are the member functions, and
rem this stuff here is the class definition. It is also dynamic, and completely
rem driven by the network/devices/and application. In fact, I could probably
rem hide the actual data, too...but why bother? I've already got all the
rem advantages of OOP without suffering the ills of BASIC too much.
type FEATURES
regular_mem_pages as word rem regular pages, unsigned LSB first
regular_mem_bytes_per_page as word rem bytes per page in regular memory
status_mem_pages as word rem status pages, unsigned LSB first
status_mem_bytes_per_page as word rem bytes per page in status memory
max_speed as word rem max communication speed: reg/OD/HD
memory_type as word rem memory type
rem 0 = NOMEM
rem 1 = NVRAM
rem 2 = EPROM
rem 3 = EPROM2
rem 4 = EPROM3
rem 5 = EEPROM1
rem 6 = MNVRAM
rem 7 = EEPROM2
rem 8 = NVRAM2
rem 9 = NVRAM3
word_6 as word rem FUTURE EXPANSION.
word_7 as word rem FUTURE EXPANSION.
word_8 as word rem FUTURE EXPANSION.
word_9 as word rem FUTURE EXPANSION.
word_10 as word rem FUTURE EXPANSION.
word_11 as word rem FUTURE EXPANSION.
word_12 as word rem FUTURE EXPANSION.
word_13 as word rem FUTURE EXPANSION.
word_14 as word rem FUTURE EXPANSION.
word_15 as word rem FUTURE EXPANSION.
word_16 as word rem FUTURE EXPANSION.
word_17 as word rem FUTURE EXPANSION.
word_18 as word rem FUTURE EXPANSION.
word_19 as word rem FUTURE EXPANSION.
word_20 as word rem FUTURE EXPANSION.
word_21 as word rem FUTURE EXPANSION.
word_22 as word rem FUTURE EXPANSION.
word_23 as word rem FUTURE EXPANSION.
word_24 as word rem FUTURE EXPANSION.
word_25 as word rem FUTURE EXPANSION.
word_26 as word rem FUTURE EXPANSION.
word_27 as word rem FUTURE EXPANSION.
word_28 as word rem FUTURE EXPANSION.
word_29 as word rem FUTURE EXPANSION.
word_30 as word rem FUTURE EXPANSION.
word_31 as word rem FUTURE EXPANSION.
endtype
rem This is an iButton device specification structure.
type SPECIFICATION
features as FEATURES
description as string
endtype
rem This is the iButton device structure definition.
type DEVICE
DeviceFamily as integer
ID_0 as integer
ID_1 as integer
ID_2 as integer
ID_3 as integer
ID_4 as integer
ID_5 as integer
CRC_8 as integer
specification as SPECIFICATION
reg_membuff_blk as integer
status_membuff_blk as integer
endtype
rem This is a 1-Wire Network connection structure definition.
type NETCONNECTION
ibfs32 as integer
portNumber as word
portType as word
sessionHandle as integer
setupReturn as integer
endSessionReturn as integer
sessionAPIReturn as integer
fileopsAPIReturn as integer
transportAPIReturn as integer
networkAPIReturn as integer
hardwareAPIReturn as integer
sessionFlags as integer
bSetup as boolean
totalDevices as integer
ROM_blk as integer
stateBuffer_blk as integer
adapter as SPECIFICATION
sessionDLLVersion as string
adapterDLLVersion as string
endtype
rem Helpful constants
#constant TRUE = 1
#constant FALSE = 0
#constant NULL = 0
#constant NULLSTR = ""
rem Here are some limits for things related to TMEX API and iButton devices.
#constant MAX_STATE_BUFFER = 15360
#constant NO_EPROM_STATE_BUFFER = 5120
#constant MSEC_DELAY = 500
rem Here are the current memory types.
#constant NOMEM = 0
#constant NVRAM = 1
#constant EPROM = 2
#constant EPROM2 = 3
#constant EPROM3 = 4
#constant EEPROM1 = 5
#constant MNVRAM = 6
#constant EEPROM2 = 7
#constant NVRAM2 = 8
#constant NVRAM3 = 9
remstart
These are indices for the function call names in the TMEX API dll,
ibfs32.dll The string array TMEX contains the strings.
remend
rem TMEX Session API
#constant TMExtendedStartSession = 0
#constant TMStartSession = 1
#constant TMValidSession = 2
#constant TMEndSession = 3
rem TMEX File Operations API
#constant TMFirstFile = 4
#constant TMNextFile = 5
#constant TMOpenFile = 6
#constant TMCreateFile = 7
#constant TMCloseFile = 8
#constant TMReadFile = 9
#constant TMWriteFile = 10
#constant TMDeleteFile = 11
#constant TMFormat = 12
#constant TMAttribute = 13
#constant TMReNameFile = 14
#constant TMChangeDirectory = 15
#constant TMDirectoryMR = 16
#constant TMCreateProgramJob = 17
#constant TMDoProgramJob = 18
#constant TMWriteAddFile = 19
#constant TMTerminateAddFile = 20
#constant TMGetFamilySpec = 21
#constant Get_Version = 22
rem TMEX Transport API
#constant TMReadPacket = 23
#constant TMWritePacket = 24
#constant TMBlockIO = 25
#constant TMExtendedReadPage = 26
#constant TMProgramByte = 27
#constant TMProgramBlock = 28
#constant TMCRC = 29
rem TMEX Network API
#constant TMFirst = 30
#constant TMNext = 31
#constant TMAccess = 32
#constant TMStrongAccess = 33
#constant TMStrongAlarmAccess = 34
#constant TMOverAccess = 35
#constant TMRom = 36
#constant TMFirstAlarm = 37
#constant TMNextAlarm = 38
#constant TMFamilySearchSetup = 39
#constant TMSkipFamily = 40
#constant TMAutoOverDrive = 41
#constant TMSearch = 42
rem TMEX Hardware API
#constant TMSetup = 43
#constant TMTouchByte = 44
#constant TMTouchReset = 45
#constant TMTouchBit = 46
#constant TMProgramPulse = 47
#constant TMOneWireLevel = 48
#constant TMOneWireCom = 49
#constant TMClose = 50
#constant TMGetTypeVersion = 51
#constant TMBlockStream = 52
#constant TMReadDefaultPort = 53
#constant TMGetAdapterSpec = 54
remstart
Returns from the TMEX API File operations group. Use for return values.
The string array, TMEXFileIOReturn has the error text.
remend
#constant NO_DEVICE = -1
#constant WRONG_TYPE = -2
#constant FILE_READ_ERR = -3
#constant BUFFER_TOO_SMALL = -4
#constant HANDLE_NOT_AVAIL = -5
#constant FILE_NOT_FOUND = -6
#constant REPEAT_FILE = -7
#constant HANDLE_NOT_USED = -8
#constant FILE_WRITE_ONLY = -9
#constant OUT_OF_SPACE = -10
#constant FILE_WRITE_ERR = -11
#constant FILE_READ_ONLY = -12
#constant FUNC_NOT_SUP = -13
#constant BAD_FILENAME = -14
#constant CANT_DEL_READ_ONLY = -15
#constant HANDLE_NOT_EXIST = -16
#constant ONE_WIRE_PORT_ERROR = -17
#constant INVALID_DIRECTORY = -18
#constant DIRECTORY_NOT_EMPTY = -19
#constant UNABLE_TO_CREATE_DIR = -20
#constant NO_PROGRAM_JOB = -21
#constant PROGRAM_WRITE_PROTECT = -22
#constant NON_PROGRAM_PARTS = -23
#constant ADDFILE_TERMINATED = -24
#constant INVALID_SESSION = -200
#constant HS_NOT_FOUND = -201
remstart
Start of global variables.
remend
global tempStr1 as string = NULLSTR
global displayStr as string = NULLSTR
global timeStr as string = NULLSTR
global iTemp as integer = 0
global isetup as integer = 0
global temp as integer = 0
global screen_width as integer = 0
global screen_height as integer = 0
global mid_x as integer = 0
global mid_y as integer = 0
global this as NETCONNECTION
global lasttime as dword = 0
global nowtime as dword = 0
global timesegment as dword = 0
global milliseconds as integer = 0
global seconds as integer = 0
global minutes as integer = 0
global hours as integer = 0
global tick as boolean = FALSE
dim Devices() as DEVICE
remstart TMEX is divided into APIs which correspond to the OSI 7-layer model.
There are currently 55 functions in the API dll, ibfs32.dll
remend
dim TMEX(55) as string
rem TMEX Session API function calls.
TMEX(TMExtendedStartSession) = "TMExtendedStartSession"
TMEX(TMStartSession) = "TMStartSession"
TMEX(TMValidSession) = "TMValidSession"
TMEX(TMEndSession) = "TMEndSession"
rem TMEX File Operations API function calls.
TMEX(TMFirstFile) = "TMFirstFile"
TMEX(TMNextFile) = "TMNextFile"
TMEX(TMOpenFile) = "TMOpenFile"
TMEX(TMCreateFile) = "TMCreateFile"
TMEX(TMCloseFile) = "TMCloseFile"
TMEX(TMReadFile) = "TMReadFile"
TMEX(TMWriteFile) = "TMWriteFile"
TMEX(TMDeleteFile) = "TMDeleteFile"
TMEX(TMFormat) = "TMFormat"
TMEX(TMAttribute) = "TMAttribute"
TMEX(TMReNameFile) = "TMReNameFile"
TMEX(TMChangeDirectory) = "TMChangeDirectory"
TMEX(TMDirectoryMR) = "TMDirectoryMR"
TMEX(TMCreateProgramJob) = "TMCreateProgramJob"
TMEX(TMDoProgramJob) = "TMDoProgramJob"
TMEX(TMWriteAddFile) = "TMWriteAddFile"
TMEX(TMTerminateAddFile) = "TMTerminateAddFile"
TMEX(TMGetFamilySpec) = "TMGetFamilySpec"
TMEX(Get_Version) = "Get_Version"
rem TMEX Transport API
TMEX(TMReadPacket) = "TMReadPacket"
TMEX(TMWritePacket) = "TMWritePacket"
TMEX(TMBlockIO) = "TMBlockIO"
TMEX(TMExtendedReadPage) = "TMExtendedReadPage"
TMEX(TMProgramByte) = "TMProgramByte"
TMEX(TMProgramBlock) = "TMProgramBlock"
TMEX(TMCRC) = "TMCRC"
rem TMEX Network API function calls.
TMEX(TMFirst) = "TMFirst"
TMEX(TMNext) = "TMNext"
TMEX(TMAccess) = "TMAccess"
TMEX(TMStrongAccess) = "TMStrongAccess"
TMEX(TMStrongAlarmAccess) = "TMStrongAlarmAccess"
TMEX(TMOverAccess) = "TMOverAccess"
TMEX(TMRom) = "TMRom"
TMEX(TMFirstAlarm) = "TMFirstAlarm"
TMEX(TMNextAlarm) = "TMNextAlarm"
TMEX(TMFamilySearchSetup) = "TMFamilySearchSetup"
TMEX(TMSkipFamily) = "TMSkipFamily"
TMEX(TMAutoOverDrive) = "TMAutoOverDrive"
TMEX(TMSearch) = "TMSearch"
rem TMEX Hardware API function calls.
TMEX(TMSetup) = "TMSetup"
TMEX(TMTouchByte) = "TMTouchByte"
TMEX(TMTouchReset) = "TMTouchReset"
TMEX(TMTouchBit) = "TMTouchBit"
TMEX(TMProgramPulse) = "TMProgramPulse"
TMEX(TMOneWireLevel) = "TMOneWireLevel"
TMEX(TMOneWireCom) = "TMOneWireCom"
TMEX(TMClose) = "TMClose"
TMEX(TMGetTypeVersion) = "TMGetTypeVersion"
TMEX(TMBlockStream) = "TMBlockStream"
TMEX(TMReadDefaultPort) = "TMReadDefaultPort"
TMEX(TMGetAdapterSpec) = "TMGetAdapterSpec"
dim TMEXSetupReturn(12) as string
TMEXSetupReturn(0) = "Setup failed."
TMEXSetupReturn(1) = "Setup ok."
TMEXSetupReturn(2) = "Setup ok, but 1-Wire network shorted."
TMEXSetupReturn(3) = "1-Wire network does not exist."
TMEXSetupReturn(4) = "TMSetup not supported."
TMEXSetupReturn(5) = "Port not initialized by call to TMSetup."
TMEXSetupReturn(6) = "1-Wire network does not exist."
TMEXSetupReturn(7) = "Function not supported."
TMEXSetupReturn(8) = "Failure to communicate with hardware adapter."
TMEXSetupReturn(9) = "Unsolicited event on 1-Wire network."
TMEXSetupReturn(10) = "Session not valid."
TMEXSetupReturn(11) = "Required hardware driver not found."
dim TMEXFileIOReturn(26) as string
TMEXFileIOReturn(0) = "Device not found."
TMEXFileIOReturn(1) = "Operation not suuported."
TMEXFileIOReturn(2) = "Read error."
TMEXFileIOReturn(3) = "Read buffer overrun."
TMEXFileIOReturn(4) = "Handle not available."
TMEXFileIOReturn(5) = "File not found."
TMEXFileIOReturn(6) = "File already exists."
TMEXFileIOReturn(7) = "Handle does not reference a file."
TMEXFileIOReturn(8) = "Attempt to read a write only file."
TMEXFileIOReturn(9) = "Out of space to write."
TMEXFileIOReturn(10) = "Device not found."
TMEXFileIOReturn(11) = "Write error. Possible unit malfunction."
TMEXFileIOReturn(12) = "Attempt to write a read only handle."
TMEXFileIOReturn(13) = "Function not supported."
TMEXFileIOReturn(14) = "Illegal name."
TMEXFileIOReturn(15) = "Cannot delete read only file."
TMEXFileIOReturn(16) = "1-Wire network error. Check setup."
TMEXFileIOReturn(17) = "Invalid directory."
TMEXFileIOReturn(18) = "Directory not empty."
TMEXFileIOReturn(19) = "Cannot exceed 10 directories in depth."
TMEXFileIOReturn(20) = "No program job started."
TMEXFileIOReturn(21) = "Program is write protected."
TMEXFileIOReturn(22) = "Non-EPROM parts detected during attempt to program."
TMEXFileIOReturn(23) = "Cannot append to terminated AddFile."
TMEXFileIOReturn(24) = "Session invalid."
TMEXFileIOReturn(25) = "Required hardware-specific driver not found."
dim deviceMemoryTypeStr(10) as string
deviceMemoryTypeStr(NOMEM) = "-NONE-"
deviceMemoryTypeStr(NVRAM) = "NVRAM"
deviceMemoryTypeStr(EPROM) = "EPROM"
deviceMemoryTypeStr(EPROM2) = "EPROM2"
deviceMemoryTypeStr(EPROM3) = "EPROM3"
deviceMemoryTypeStr(EEPROM1) = "EEPROM1"
deviceMemoryTypeStr(MNVRAM) = "MNVRAM"
deviceMemoryTypeStr(EEPROM2) = "EEPROM2"
deviceMemoryTypeStr(NVRAM2) = "NVRAM2"
deviceMemoryTypeStr(NVRAM3) = "NVRAM3"
remstart
Here is a sort of laundry list of things about how DBPro and the
1-Wire SDK do not marry up automatically, and what I do in each case.
1. The TMEX API returns short integers in most cases. A notable exception
is TMEXExtendedStartSession, which returns a long. That is the direct
equivalent of DBPro's integer type. Nothing is done in that case, and
iSessionHandle is used as is. DBPro will return a DWORD type, which
has the unpleasant side-effect of destroying the sign of short integer
returns from dlls if you use the return as a DWORD, or even as an
integer. The function jzMakeWordIntValue is used when the TMEX API is
trying to return a short integer to DBPro. It preserves the sign and
value of the original dll return while converting to the DBPro integer
type.
2. Strings are C-style null terminated ASCII character arrays. I have
provided translation to DBPro strings.
3. Structures are passed via memory blocks, and DWORD pointers are used
for passing addresses to the functions that require them.
4. I ply DBPro's dynamic array capability to create a dynamic device
array based on the UDT DEVICE. This type should be expanded to
encompass all of the like data about iButtons. Currently, it does that
for the most basic of all iButtons, the ID Button. I imagine a space for
a memblock ID will be sufficient in most cases, but the file system,
alarms and some of the other features will need specific attention.
mtb11.12.2006
remend
rem ************************* START OF PROGRAM EXECUTION **********************
empty array Devices()
this.portNumber = 0xffff
this.portType = 0xffff
this.sessionHandle = -1
this.sessionAPIReturn = -1
this.fileopsAPIReturn = -1
this.transportAPIReturn = -1
this.networkAPIReturn = -1
this.hardwareAPIReturn = -1
this.bSetup = FALSE
this.totalDevices = 0
this.ROM_blk = 0
this.stateBuffer_blk = 0
this.adapter.features.regular_mem_pages = 0x0000
this.adapter.features.regular_mem_bytes_per_page = 0x0000
this.adapter.features.status_mem_pages = 0x0000
this.adapter.features.status_mem_bytes_per_page = 0x0000
this.adapter.features.max_speed = 0x0000
this.adapter.features.memory_type = 0x0000
this.adapter.features.word_6 = 0x0000
this.adapter.features.word_7 = 0x0000
this.adapter.features.word_8 = 0x0000
this.adapter.features.word_9 = 0x0000
this.adapter.features.word_10 = 0x0000
this.adapter.features.word_11 = 0x0000
this.adapter.features.word_12 = 0x0000
this.adapter.features.word_13 = 0x0000
this.adapter.features.word_14 = 0x0000
this.adapter.features.word_15 = 0x0000
this.adapter.features.word_16 = 0x0000
this.adapter.features.word_17 = 0x0000
this.adapter.features.word_18 = 0x0000
this.adapter.features.word_19 = 0x0000
this.adapter.features.word_20 = 0x0000
this.adapter.features.word_21 = 0x0000
this.adapter.features.word_22 = 0x0000
this.adapter.features.word_23 = 0x0000
this.adapter.features.word_24 = 0x0000
this.adapter.features.word_25 = 0x0000
this.adapter.features.word_26 = 0x0000
this.adapter.features.word_27 = 0x0000
this.adapter.features.word_28 = 0x0000
this.adapter.features.word_29 = 0x0000
this.adapter.features.word_30 = 0x0000
this.adapter.features.word_31 = 0x0000
this.adapter.description = "INVALID! Uninitialized."
this.sessionDLLVersion = "UNINITIALIZED."
this.adapterDLLVersion = "UNINITIALIZED."
set display mode 800, 600, 16
set window on
set window layout 1, 1, 1
sync on
sync rate 0
backdrop off
set text transparent
set text font "terminal"
set text size 18
set text to bold
screen_width = screen width()
screen_height = screen height()
mid_x = screen_width >> 1
mid_y = screen_height >> 1
lasttime = timer()
Initialize1WireNetwork()
do
cls
nowtime = timer()
timesegment = nowtime - lasttime
inc milliseconds, timesegment
if milliseconds > 999
inc seconds
dec milliseconds, 1000
tick = TRUE
if seconds > 59
inc minutes
dec seconds, 60
if minutes > 59
inc hours
dec minutes, 60
endif
endif
endif
center text mid_x, 0, "~~~~~~~~~~ 1-Wire Network ~~~~~~~~~~"
set cursor 0, 20
print "TMEX DLL version : " + Get1WireNetworkSessionDLLVersion()
print "Adapter version : " + Get1WireNetworkAdapterDLLVersion()
print "Adapter Description string : " + Get1WireNetworkAdapterDescription()
print "Connect port = " + str$(Get1WireNetworkPortNumber()) + "/Type = " + ...
str$(Get1WireNetworkPortType())
isetup = Get1WireNetworkSetupReturn()
if Is1WireNetworkAdapterSetup() = TRUE and isetup < 5
print TMEXSetupReturn(isetup)
else
select isetup
case -1
print TMEXSetupReturn(5)
endcase
case -2
print TMEXSetupReturn(6)
endcase
case -3
print TMEXSetupReturn(7)
endcase
case -12
print TMEXSetupReturn(8)
endcase
case -13
print TMEXSetupReturn(9)
endcase
case -200
print TMEXSetupReturn(10)
endcase
case -201
print TMEXSetupReturn(11)
endcase
case default
print "Setup returned "; isetup
endcase
endselect
endif
print "session handle : " + str$(Get1WireNetworkSessionHandle())
print "Program runtime : " + str$(hours) + " hours " + ...
str$(minutes) + " minutes " + ...
str$(seconds) + " seconds."
print jzDupStr("~", 132)
print space$(6) + "[-ROM ID-]" + space$(37) + "[-Description-]" + ...
space$(35) + "[-Memory-]" + space$(4) + "[-Speed-]" + ...
space$(4) + "[RMem]" + space$(4) + "[SMem]"
print jzDupStr("~", 132)
for temp = 0 to array count(Devices())
print GetDeviceROMIDStr(temp) + space$(6) + ...
GetDeviceName(temp) + "/" + GetDeviceAlternateName(temp) + " " + ...
GetDeviceDescription(temp) + space$(12) + ...
deviceMemoryTypeStr(GetDeviceMemoryType(temp)) + space$(16) + ...
str$(GetDeviceMaxSpeed(temp)) + space$(12) + ...
str$(GetDeviceRegularMemoryPages(temp)) + "/" + ...
str$(GetDeviceRegularMemoryBytesPerPage(temp)) + space$(12) + ...
str$(GetDeviceStatusMemoryPages(temp)) + "/" + ...
str$(GetDeviceStatusMemoryBytesPerPage(temp))
next temp
lasttime = nowtime
if tick = TRUE
tick = FALSE
GetValidSession()
endif
sync
loop
end
rem **********************End Main Program*************************
remstart
ibfs32.dll is the session dll. It provides the link into the 1-Wire
Network's lower layers.
remend
remstart Initialize1WireNetwork()
This routine is fairly straightforward. It gets some resources,
and starts up the 1-Wire Network in accordance with the TMEX API
design guidelines.
MTB11.10.2006
remend
function Initialize1WireNetwork()
local dwWordPtr1 as dword
local dwWordPtr2 as dword
local wTemp as word
local temp as integer
rem 1. Load DLL if necessary.
if this.ibfs32 < 1
this.ibfs32 = jzGetNextAvailableDLLID(FALSE, 1)
load dll "ibfs32.dll", this.ibfs32
endif
rem 2. Get a buffer for the devices' ROM bytes.
if this.ROM_blk = 0
this.ROM_blk = jzGetNextAvailableMemblockID(1)
make memblock this.ROM_blk, 16
endif
if this.stateBuffer_blk = 0
this.stateBuffer_blk = jzGetNextAvailableMemblockID(1)
make memblock this.stateBuffer_blk, MAX_STATE_BUFFER
endif
rem 3. Get the ibfs32.dll version string and store globally.
rem ibfs32.dll will read the registry for a default port and type.
rem Get the adapter driver version string and store globally.
this.sessionDLLVersion = NULLSTR
this.sessionDLLVersion = space$(80)
wTemp = call dll(this.ibfs32, TMEX(Get_Version), this.sessionDLLVersion)
this.fileopsAPIReturn = jzMakeWordIntValue(wTemp)
dwWordPtr1 = make memory(2)
dwWordPtr2 = make memory(2)
wTemp = call dll(this.ibfs32, TMEX(TMReadDefaultPort), ...
dwWordPtr1, dwWordPtr2)
this.hardwareAPIReturn = jzMakeWordIntValue(wTemp)
this.portNumber = *dwWordPtr1
this.portType = *dwWordPtr2
delete memory dwWordPtr1
delete memory dwWordPtr2
this.adapterDLLVersion = space$(80)
wTemp = call dll(this.ibfs32, TMEX(TMGetTypeVersion), ...
this.portType, this.adapterDLLVersion)
this.hardwareAPIReturn = jzMakeWordIntValue(wTemp)
rem 4. Start the session. You must call TMExtendedStartSession first.
rem Next, you must call TMSetup. TMGetAdapterSpec is not necessary,
rem but it pays to know about the adapter's capabilities up front.
temp = GetSessionHandle(this.sessionFlags)
if this.sessionHandle > 0 and this.bSetup
if GetAdapterSpec() > 0
EnumerateDevices()
endif
endif
endfunction TRUE
function GetSessionHandle(sessionflags as DWORD)
local dwptr as dword
local wTemp as word
dwptr = make memory(4)
*dwptr = sessionflags
this.sessionHandle = call dll(this.ibfs32, TMEX(TMExtendedStartSession), ...
this.portNumber, this.portType, dwptr)
delete memory dwptr
if this.sessionHandle > 0
this.endSessionReturn = 0
if this.bSetup = FALSE
wTemp = call dll(this.ibfs32, TMEX(TMSetup), this.sessionHandle)
this.hardwareAPIReturn = jzMakeWordIntValue(wTemp)
this.setupReturn = this.hardwareAPIReturn
if this.setupReturn > 0
this.bSetup = TRUE
endif
endif
else
exitfunction 0
endif
endfunction this.sessionHandle
function GetValidSession()
local iValid as integer
local wTemp as word
wTemp = call dll(this.ibfs32, TMEX(TMValidSession), this.sessionHandle)
iValid = jzMakeWordIntValue(wTemp)
if iValid <> 1
iValid = GetSessionHandle(dwSessionFlags)
if iValid <> 0
EnumerateDevices()
else
this.totalDevices = 0
if array count(Devices()) <> -1
empty array Devices()
endif
endif
endif
endfunction iValid
function ShutDown()
local iValid as integer
local wTemp as word
wTemp = call dll(this.ibfs32, TMEX(TMValidSession), this.sessionHandle)
iValid = jzMakeWordIntValue(wTemp)
if iValid
this.sessionAPIReturn = call dll(this.ibfs32, TMEX(TMEndSession), ...
this.sessionHandle)
this.endSessionReturn = this.sessionAPIReturn
endif
if this.ibfs32 > 0 and this.ibfs32 < 256
delete dll this.ibfs32
this.ibfs32 = 0
endif
if this.stateBuffer_blk <> 0
delete memory this.stateBuffer_blk
this.stateBuffer_blk = 0
endif
if this.ROM_blk > 0 and memblock exist(this.ROM_blk) = 1
delete memblock this.ROM_blk
endif
endfunction
function EnumerateDevices()
local totalDevices as integer = 0
local count as integer = 0
local dwROMptr as dword = 0
local dwTempPtr as dword = 0
local dwTempPtr2 as dword = 0
local offset as integer = 0
local spec_blk as integer = 0
local temp_blk as integer = 0
local wTemp as word
rem 1. Always a good idea to do this, although the first time it should
rem be empty already.
empty array Devices()
this.totalDevices = 0
rem 2. TMFirst and TMNext require a pointer to a state buffer.
dwTempPtr = get memblock ptr(this.stateBuffer_blk)
fill memory dwTempPtr, 0x00, MAX_STATE_BUFFER
dwROMptr = get memblock ptr(this.ROM_blk)
fill memory dwROMptr, 0x00, 16
wTemp = call dll(this.ibfs32, TMEX(TMFirst), this.sessionHandle, dwTempPtr)
this.networkAPIReturn = jzMakeWordIntValue(wTemp)
if this.networkAPIReturn > 0
spec_blk = jzGetNextAvailableMemblockID(1)
make memblock spec_blk, 319
dwTempPtr2 = get memblock ptr(spec_blk)
fill memory dwTempPtr2, 0x00, 319
wTemp = call dll(this.ibfs32, TMEX(TMRom), this.sessionHandle, dwTempPtr, ...
dwROMptr)
this.networkAPIReturn = jzMakeWordIntValue(wTemp)
if this.networkAPIReturn > 0
offset = 0
this.totalDevices = 1
array insert at bottom Devices()
Devices().DeviceFamily = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_0 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_1 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_2 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_3 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_4 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_5 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().CRC_8 = memblock word(this.ROM_blk, offset)
Devices().specification.description = "INVALID: UNINITIALIZED."
wTemp = call dll(this.ibfs32, TMEX(TMGetFamilySpec), ...
this.sessionHandle, dwTempPtr, dwTempPtr2)
this.fileopsAPIReturn = jzMakeWordIntValue(wTemp)
if this.fileopsAPIReturn > 0
offset = 0
Devices().specification.features.regular_mem_pages = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.regular_mem_bytes_per_page = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.status_mem_pages = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.status_mem_bytes_per_page = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.max_speed = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.memory_type = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_6 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_7 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_8 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_9 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_10 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_11 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_12 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_13 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_14 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_15 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_16 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_17 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_18 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_19 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_20 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_21 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_22 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_23 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_24 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_25 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_26 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_27 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_28 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_29 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_30 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_31 = ...
memblock word(spec_blk, offset)
temp_blk = jzGetNextAvailableMemblockID(1)
make memblock temp_blk, 255
dwTempPtr2 = get memblock ptr(temp_blk)
fill memory dwTempPtr2, 0x00, 255
copy memblock spec_blk, temp_blk, 64, 0, 255
Devices().specification.description = ...
jzMakeDBString(temp_blk, 255)
Devices().reg_membuff_blk = -1
Devices().status_membuff_blk = -1
endif
endif
while this.networkAPIReturn > 0
wTemp = call dll(this.ibfs32, TMEX(TMNext), this.sessionHandle, ...
dwTempPtr)
this.networkAPIReturn = jzMakeWordIntValue(wTemp)
if this.networkAPIReturn < 1 then exit
inc this.totalDevices
write memblock word this.ROM_blk, 0, 0x0000
dwTempPtr2 = get memblock ptr(spec_blk)
fill memory dwTempPtr2, 0x00, 319
wTemp = call dll(this.ibfs32, TMEX(TMRom), this.sessionHandle, ...
dwTempPtr, dwROMptr)
this.networkAPIReturn = jzMakeWordIntValue(wTemp)
if this.networkAPIReturn > 0
offset = 0
array insert at bottom Devices()
Devices().DeviceFamily = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_0 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_1 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_2 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_3 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_4 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().ID_5 = memblock word(this.ROM_blk, offset)
inc offset, 2
Devices().CRC_8 = memblock word(this.ROM_blk, offset)
Devices().specification.description = ...
"INVALID: UNINITIALIZED."
wTemp = call dll(this.ibfs32, TMEX(TMGetFamilySpec), ...
this.sessionHandle, dwTempPtr, dwTempPtr2)
this.fileopsAPIReturn = jzMakeWordIntValue(wTemp)
if this.fileopsAPIReturn > 0
offset = 0
Devices().specification.features.regular_mem_pages = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.regular_mem_bytes_per_page = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.status_mem_pages = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.status_mem_bytes_per_page = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.max_speed = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.memory_type = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_6 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_7 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_8 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_9 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_10 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_11 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_12 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_13 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_14 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_15 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_16 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_17 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_18 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_19 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_10 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_21 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_22 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_23 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_24 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_25 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_26 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_27 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_28 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_29 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_30 = ...
memblock word(spec_blk, offset)
inc offset, 2
Devices().specification.features.word_31 = ...
memblock word(spec_blk, offset)
dwTempPtr2 = get memblock ptr(temp_blk)
fill memory dwTempPtr2, 0x00, 255
copy memblock spec_blk, temp_blk, 64, 0, 255
Devices().specification.description = ...
jzMakeDBString(temp_blk, 255)
Devices().reg_membuff_blk = -1
Devices().status_membuff_blk = -1
endif
endif
endwhile
else
this.sessionAPIReturn = call dll(this.ibfs32, TMEX(TMEndSession), ...
this.sessionHandle)
this.endSessionReturn = this.sessionAPIReturn
endif
if spec_blk <> 0 and memblock exist(spec_blk) = 1
delete memblock spec_blk
endif
if temp_blk <> 0 and memblock exist(temp_blk) = 1
delete memblock temp_blk
endif
endfunction
remstart GetAdapterSpec()
The 1-Wire Network TMEX API documentation has an incorrect prototype
for this function call. You do not pass a pointer to the state buffer.
The example code shows the correct format of this call, which is used
here. Also, a return of 0 is not an error.
MTB11.10.2006
remend
function GetAdapterSpec()
local dwptr1 as dword
local offset as dword
local spec_blk as integer
local temp_blk as integer
local ireturn as integer
local wTemp as word
rem 1. Initialize global variables to known values.
this.adapter.features.regular_mem_pages = 0x0000
this.adapter.features.regular_mem_bytes_per_page = 0x0000
this.adapter.features.status_mem_pages = 0x0000
this.adapter.features.status_mem_bytes_per_page = 0x0000
this.adapter.features.max_speed = 0x0000
this.adapter.features.memory_type = 0x0000
this.adapter.features.word_6 = 0x0000
this.adapter.features.word_7 = 0x0000
this.adapter.features.word_8 = 0x0000
this.adapter.features.word_9 = 0x0000
this.adapter.features.word_10 = 0x0000
this.adapter.features.word_11 = 0x0000
this.adapter.features.word_12 = 0x0000
this.adapter.features.word_13 = 0x0000
this.adapter.features.word_14 = 0x0000
this.adapter.features.word_15 = 0x0000
this.adapter.features.word_16 = 0x0000
this.adapter.features.word_17 = 0x0000
this.adapter.features.word_18 = 0x0000
this.adapter.features.word_19 = 0x0000
this.adapter.features.word_20 = 0x0000
this.adapter.features.word_21 = 0x0000
this.adapter.features.word_22 = 0x0000
this.adapter.features.word_23 = 0x0000
this.adapter.features.word_24 = 0x0000
this.adapter.features.word_25 = 0x0000
this.adapter.features.word_26 = 0x0000
this.adapter.features.word_27 = 0x0000
this.adapter.features.word_28 = 0x0000
this.adapter.features.word_29 = 0x0000
this.adapter.features.word_30 = 0x0000
this.adapter.features.word_31 = 0x0000
this.adapter.description = "INVALID! Uninitialized."
rem 2. Get a memblock for the data that is going to be returned.
rem Also, get a pointer for it to pass to the dll.
spec_blk = jzGetNextAvailableMemblockID(1)
make memblock spec_blk, 319
dwptr1 = get memblock ptr(spec_blk)
rem 3. It is a very good practice to call GetValidSession() before
rem making any calls into the network. Here, it is only next door,
rem but the session can get invalidated. GetValidSession() attempts
rem to fix that.
if GetValidSession()
wTemp = call dll(this.ibfs32, TMEX(TMGetAdapterSpec), this.sessionHandle, ...
dwptr1)
this.hardwareAPIReturn = jzMakeWordIntValue(wTemp)
if this.hardwareAPIReturn = 1
rem 4. Copy returned data into global variables.
this.adapter.features.regular_mem_pages = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.regular_mem_bytes_per_page = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.status_mem_pages = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.status_mem_bytes_per_page = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.max_speed = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.memory_type = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_6 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_7 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_8 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_9 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_10 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_11 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_12 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_13 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_14 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_15 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_16 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_17 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_18 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_19 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_20 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_21 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_22 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_23 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_24 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_25 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_26 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_27 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_28 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_29 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_30 = ...
memblock word(spec_blk, offset)
inc offset, 2
this.adapter.features.word_31 = ...
memblock word(spec_blk, offset)
rem N.B. Here, it is easier to use a more generic routine to create a
rem DBPro string by copying the string data into a new memblock.
temp_blk = jzGetNextAvailableMemblockID(1)
make memblock temp_blk, 255
dwptr1 = get memblock ptr(temp_blk)
fill memory dwptr1, 0x00, 255
copy memblock spec_blk, temp_blk, 64, 0, 255
this.adapter.description = jzMakeDBString(temp_blk, 255)
delete memblock temp_blk
endif
endif
delete memblock spec_blk
endfunction this.hardwareAPIReturn
remstart ************************************************************************
Here are the class member functions for 1-Wire Network connections.
******************************************************************remend
function Get1WireNetworkSessionDLLVersion()
endfunction this.sessionDLLVersion
function Get1WireNetworkAdapterDLLVersion()
endfunction this.adapterDLLVersion
function Get1WireNetworkAdapterDescription()
endfunction this.adapter.description
function Get1WireNetworkSessionHandle()
endfunction this.sessionHandle
function Get1WireNetworkPortNumber()
local i as integer
i = int(this.portNumber)
endfunction i
function Get1WireNetworkPortType()
local i as integer
i = int(this.portType)
endfunction i
function Get1WireNetworkFileOperationsAPIReturn()
endfunction this.fileopsAPIReturn
function Get1WireNetworkTransportAPIReturn()
endfunction this.transportAPIReturn
function Get1WireNetworkNetworkAPIReturn()
endfunction this.networkAPIReturn
function Get1WireNetworkHardwareAPIReturn()
endfunction this.hardwareAPIReturn
function Is1WireNetworkAdapterSetup()
endfunction this.bSetup
function Get1WireNetworkSetupReturn()
endfunction this.setupReturn
function Get1WireNetworkTotalDevices()
i as integer = array count(Devices())
if i = -1 then i = 0
endfunction i
remstart ******************************************************************
Here are the class member functions for Devices.
******************************************************************remend
function GetDeviceROMIDStr(device as integer)
local ROMIDstr as string = "Device number INVALID."
local tempstr1 as string
local tempstr2 as string
local tempstr3 as string
local tempstr4 as string
local tempstr5 as string
local tempstr6 as string
local tempstr7 as string
local tempstr8 as string
if device > -1 and device < array count(Devices()) + 1
ROMIDstr = NULLSTR
tempstr1 = hex$(int(Devices(device).CRC_8))
tempstr2 = hex$(int(Devices(device).ID_5))
tempstr3 = hex$(int(Devices(device).ID_4))
tempstr4 = hex$(int(Devices(device).ID_3))
tempstr5 = hex$(int(Devices(device).ID_2))
tempstr6 = hex$(int(Devices(device).ID_1))
tempstr7 = hex$(int(Devices(device).ID_0))
tempstr8 = hex$(int(Devices(device).DeviceFamily))
if len(tempstr1) = 1
ROMIDstr = "0"
endif
ROMIDstr = ROMIDstr + tempstr1
if len(tempstr2) = 1
ROMIDstr = ROMIDstr + "0"
endif
ROMIDstr = ROMIDstr + tempstr2
if len(tempstr3) = 1
ROMIDstr = ROMIDstr + "0"
endif
ROMIDstr = ROMIDstr + tempstr3
if len(tempstr4) = 1
ROMIDstr = ROMIDstr + "0"
endif
ROMIDstr = ROMIDstr + tempstr4
if len(tempstr5) = 1
ROMIDstr = ROMIDstr + "0"
endif
ROMIDstr = ROMIDstr + tempstr5
if len(tempstr6) = 1
ROMIDstr = ROMIDstr + "0"
endif
ROMIDstr = ROMIDstr + tempstr6
if len(tempstr7) = 1
ROMIDstr = ROMIDstr + "0"
endif
ROMIDstr = ROMIDstr + tempstr7
if len(tempstr8) = 1
ROMIDstr = ROMIDstr + "0"
endif
ROMIDstr = ROMIDstr + tempstr8
endif
endfunction ROMIDstr
function GetDeviceSpecification(device as integer)
local devicenamestr as string = "Device number INVALID."
if device > -1 and device < array count(Devices()) + 1
devicenamestr = Devices(device).specification.description
endif
endfunction devicenamestr
function GetDeviceName(device as integer)
local devicenamestr as string = "Device number INVALID."
if device > -1 and device < array count(Devices()) + 1
devicenamestr = jzGetToken(Devices(device).specification.description, 1, ",")
endif
endfunction devicenamestr
function GetDeviceAlternateName(device as integer)
local devicenamestr as string = "Device number INVALID."
if device > -1 and device < array count(Devices()) + 1
devicenamestr = jzGetToken(Devices(device).specification.description, 2, ",")
endif
endfunction devicenamestr
function GetDeviceDescription(device as integer)
local devicenamestr as string = "Device number INVALID."
if device > -1 and device < array count(Devices()) + 1
devicenamestr = jzGetToken(Devices(device).specification.description, 3, ",")
endif
endfunction devicenamestr
function GetDeviceMaxSpeed(device as integer)
local max_speed as integer = -1
if device > -1 and device < array count(Devices()) + 1
max_speed = Devices(device).specification.features.max_speed
endif
endfunction max_speed
function GetDeviceMemoryType(device as integer)
local memory_type as integer = -1
if device > -1 and device < array count(Devices()) + 1
memory_type = Devices(device).specification.features.memory_type
endif
endfunction memory_type
function GetDeviceRegularMemoryPages(device as integer)
local memory_pages as integer = -1
if device > -1 and device < array count(Devices()) + 1
memory_pages = Devices(device).specification.features.regular_mem_pages
endif
endfunction memory_pages
function GetDeviceRegularMemoryBytesPerPage(device as integer)
local bytes_per_page as integer = -1
if device > -1 and device < array count(Devices()) + 1
bytes_per_page = ...
Devices(device).specification.features.regular_mem_bytes_per_page
endif
endfunction bytes_per_page
function GetDeviceStatusMemoryPages(device as integer)
local memory_pages as integer = -1
if device > -1 and device < array count(Devices()) + 1
memory_pages = Devices(device).specification.features.status_mem_pages
endif
endfunction memory_pages
function GetDeviceStatusMemoryBytesPerPage(device as integer)
local bytes_per_page as integer = -1
if device > -1 and device < array count(Devices()) + 1
bytes_per_page = ...
Devices(device).specification.features.status_mem_bytes_per_page
endif
endfunction bytes_per_page
remstart ************************************************************************
These are general purpose routines for translating types, and basically
to enable efficient use of some of the DBPro resources required. They
were all gleaned from my DBPro utility source files.
******************************************************************** remend
function jzMakeWordIntValue(wordvalue as word)
local intValue as integer
if wordvalue && 0x8000 rem This checks for a sign bit.
intValue = wordvalue - 65536 rem Quick and dirty, but accurate...100%.
else
intValue = wordvalue
endif
endfunction intValue
function jzGetNextAvailableMemblockID(seed as integer)
local temp = seed
if seed < 1 then exitfunction -1
do
if memblock exist(temp) = 0 then exitfunction temp
inc temp
if temp < 0 then exitfunction -1
loop
endfunction -1
function jzGetNextAvailableDLLID(bDown as boolean, seed as integer)
local temp = seed
if seed < 1 or seed > 255 then exitfunction -1
do
if dll exist(temp) = 0 then exitfunction temp
if bDown = 1
dec temp
else
inc temp
endif
if temp < 1 or temp > 255 then exitfunction -1
loop
endfunction -1
function jzMakeDBString(cstring_blockID as integer, maxLength as integer)
local ivalue as integer
local icount as integer
local offset as integer
local buildstr as string
offset = 0
icount = 0
buildstr = ""
ivalue = memblock byte(cstring_blockID, offset)
while ivalue <> 0
buildstr = buildstr + chr$(ivalue)
inc offset
inc icount
if icount > maxLength then exitfunction buildstr
ivalue = memblock byte(cstring_blockID, offset)
endwhile
endfunction buildstr
function jzDupStr(character as string, numtimes as integer)
local buildstr as string
local i as integer
buildstr = ""
for i = 0 to numtimes - 1
buildstr = buildstr + character
next i
endfunction buildstr
function jzGetToken(inputstr as string, token as integer, delimiter as string)
local count as integer
local found as integer = 0
local buildstr as string = NULLSTR
for count = 0 to len(inputstr)
if mid$(inputstr, count) = delimiter
inc found
if found = token
exitfunction buildstr
else
buildstr = ""
endif
else
buildstr = buildstr + mid$(inputstr, count)
endif
next count
endfunction buildstr
EDIT: I just updated this snippet, rather than post again. It is much improved over the last, I think. Now, the display is drawn only from global function calls, and I have almost made the entire connection that way.
enjoy.