OWIN
 
Syntax


#include <ONEWIRE.bas>                          ' source in /Program Files/Coridium/BASIClib

SUB OWIN (pin, OUTcnt, BYREF OUTlist as string, INcnt, BYREF INlist as string)

Description


OWIN begins with a RESET/Presence sequence on the designated Pin.

Then OUTcnt bytes will be transferred to the device to select the command. OUTcnt may be 0, with an empty string "".

Following that the INcnt bytes InputList will be read back from the device. If INcnt equals 0, then the string will be filled with bytes until a 0, CR or LF character is received.  Note that no bounds checking is performed on the input, and if a 0, CR, or LF is never received then this routine will hang.    As there is no bounds checking its possible to overwrite other variables, if less than 256 bytes have been allocated for the InputList string..

The bit order for the 1-Wire device is assumed to be LSB (bit 0) first.  The REV function can be used to change the bit order.

Example

#include <ONEWIRE.bas>

DIM outbytes(10) as string
DIM inbytes(10) as string

                 ' write to the scratch pad of a DS2430
outbytes(0)=&Hcc
outbytes(1)=&Hf
outbytes(2)=&H6
outbytes(3)=&Hbe
outbytes(4)=&H41

present = owout (7 ,5, outbytes)
print present

outbytes(0)=&Hcc
outbytes(1)=&Haa
outbytes(2)=&H6

owin (7, 3, outbytes, 2, inbytes)
print hex(inbytes(0)),hex(inbytes(1))

Differences from other BASICs

See also