Download Heron-API User Manual
Transcript
int HeronHsbSendMessageData(HeronHSB *handle, *buffer, unsigned int size) unsigned char The process of sending a message is made up of three parts. The first part involves setting up the address byte and generating the start condition on the serial bus. The second part is the transmission of all the data bytes, and the third part is ending the message and returning the bus to a free state. The function HeronHsbSendMessageData will perform the second part of message transmission. As such, this function must be used in combination with the functions HeronHsbStartSendMessage and HeronHsbEndOfSendMessage. Please note where possible, the user should use the function HeronHsbSendMessage when sending a message over HSB. The function HeronHsbSendMessageData should only be used where it is not possible to use the standard send message function. This function operates on the HSB device specified through the argument handle. This device handle is the handle returned by the function HeronHsbOpen. The buffer argument is a pointer to an array of unsigned chars. This array must contain the data bytes to be transmitted. The argument size defines the number of data bytes to be transmitted. This number must not exceed the buffer size. When using this function to send a message, it must be called after successfully starting a message through the function HeronHsbStartSendMessage. Once the message has been started this function can be called repeatedly until all message data has been transferred. For the first call to this function after starting the message, the first two data bytes supplied must be the message type byte and the reply (or source) address. The message type byte is an integer number between 0 and 255. For a further description of the message type please read the earlier section on ‘The Message Type’ in the chapter on ‘HERON Serial Bus Functions’. The reply address is generated by combining the board ID and slot number for the module on which the HSB send message is being run. The bottom three bits of the address byte must be set to the slot ID (between 0 and 7) and the next four bits of the address must be set to the board ID (between 0 and 15). The following code excerpt shows how the address would be generated for slot 2 of board 0: board = 0; slot = 2; address = slot; address = address | (board << 3); After sending the message type and source address, all remaining data bytes are optional data bytes. For each call to HeronHsbSendMessageData the function will return HERON_OK when it has successfully transmitted the number of data bytes given by the argument size. If an invalid HSB device handle is passed into HeronHsbSendMessageData, the function will return HERON_INVALID_HANDLE. If a NULL pointer is supplied through the argument buffer the function will return HERON_NULL_POINTER, and if the argument size is set to zero, the function will return HERON_HSB_ZERO_BYTE_COUNT. 55 HUNT ENGINEERING HERON-API USER MANUAL