TMWritePacket Overview Group

The TMWritePacket API call writes a Universal Data Packet (UDP) starting on 'start_page' in a 1-Wire device. The 'num_write' bytes of data in 'write_buffer' is written. Returns a byte length greater than or equal to 0 for success or one of the TRANSPORT error values for a failure. TMWritePacket works only with the nvram 1-Wire devices such as the DS1993 iButton. See the description of the Universal Data Packet.


short far pascal TMWritePacket(

long session_handle, // session handle for the desired 1-Wire network
void far *state_buffer, // state buffer provided for the 1-Wire network session
short start_page, // page number to start to write the packet
unsigned char far *write_buffer, // buffer to hold the data to write
short num_write // the number of bytes to write
);

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.

start_page

Specifies the page that the packet will begin being written at. A CRC-16 verified packet always starts at the beginning of a page boundary. The valid range of a start page depends on the device type. Current 1-Wire devices range from 0 to 256 pages.

write_buffer

Specifies a pointer to a memory location that contains the data to write. The amount of data to write is expressed in num_write.

num_write

Specifies the number of bytes in the write_buffer to write.

Return Value

>=0 => length of valid data written
<0 => TMEX Transport Error Return Code

Code Example

See Also

TMReadPacket