TMProgramBlock Overview Group

The TMProgramBlock API call writes a buffer of bytes to an EPROM device such as the DS1982, DS1985, DS1986 or DS2406. The address of the buffer to write, 'write_buf', the location, 'address, and the number of bits, 'bits,' to program are specified as parameters to the function. If the function cannot program the entire number of bits specified to be programmed the function will automatically fall back to a lower value. To expedite future calls to TMProgramBlock, the number of bits per pass is returned. If the function is forced to fall back to a lower value then use this value on subsequent calls to the function. Note that the ROM pattern for the desired 1-Wire device must already be in the internal eight-byte buffer before this function is called. This can be accomplished through a call to TMRom or by using a network API call TMFirst, TMNext, TMFirstAlarm or TMNextAlarm. This constraint enables this function to be multi-drop compatible with other EPROM devices on the 1-Wire Net. It is the responsibility of the calling program to make sure that there are no non-EPROM devices on the 1-Wire Net at the time of programming. A non-EPROM device can be damaged from the programming pulse.


short far pascal TMProgramBlock(

long session_handle, // session handle for the desired 1-Wire network
void far *state_buffer, // state buffer provided for the 1-Wire network session
uchar far *write_buf, // buffer of bytes to write to 1-Wire device
short length, // length of bytes of write_buf
short address, // the memory location to start writing
short far *bits // number of bits to program
);

For a description of the above types, see the TMEX Type Descriptions.

Parameters

session_handle

Specifies the session handle returned from the API function TMExtendedStartSession that specifies the desired 1-Wire network port. This parameter is required by most TMEX API functions.

state_buffer

Specifies a pointer to a memory location that TMEX keeps all of the state information for the 1-Wire networks. This parameter is required by most TMEX API functions.

write_buf

Specifies the buffer of bytes to write to the EPROM device.

length

Specifies the length in bytes of the write_buf buffer.

address

The memory location of the EPROM device where writing starts.

bits

The number of bits to write to the EPROM device. This variable will return the number of bits actually written and should be used in future calls to the function.

Return Value

>=0 => length of valid data read

<0 => TMEX Transport Error Return Code

Code Example

See Also

TMProgramByte