#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <limits.h>
#include "zb_serial.h"
Go to the source code of this file.
Functions | |
void | zb_set_verbose (int value) |
int | zb_encode (uint8_t *destination, uint8_t device_number, uint8_t command_number, int32_t data) |
int | zb_decode (int32_t *destination, const uint8_t *reply) |
Variables | |
static int | zb_verbose = 1 |
int zb_decode | ( | int32_t * | destination, |
const uint8_t * | reply | ||
) |
Decodes the last 4 bytes of a 6-byte (complete) reply.
This function wraps the last four bytes of the reply into a 32-bit integer matching the architecture of the compilation target (typically the machine which compiled the code, unless otherwise specified).
This function only writes the "data" portion of a reply (the last four bytes) into destination. You will still need to manually read the first two bytes of your reply to get the device and command IDs.
This function does not support the decoding of Message IDs. If your device does have Message IDs enabled, the data decoded by this function will be incorrect and should be considered undefined.
[out] | destination | a pointer to a 32-bit integer to which to write the reply's data. |
[in] | reply | a pointer to an array containing a 6-byte reply message. |
Definition at line 48 of file zb_serial.c.
int zb_encode | ( | uint8_t * | destination, |
uint8_t | device_number, | ||
uint8_t | command_number, | ||
int32_t | data | ||
) |
Encodes a command according to Zaber's Binary Protocol Manual.
This function performs the necessary transposition of data bytes for transmission to Zaber devices using the binary protocol.
This function does not support the encoding of Message IDs.
[out] | destination | a pointer to an array to which to write the encoded command. Assumed to be at least 6 bytes long. |
[in] | device_number | the number of the device to which to send the command. |
[in] | command_number | the number of the command to be sent. |
[in] | data | the data to be sent along with the command. The contents of this field depend on the command number being sent. See the Binary Protocol Manual for info on specific commands. |
Definition at line 25 of file zb_serial.c.
void zb_set_verbose | ( | int | value | ) |
Sets whether errors and extra info are reported to stderr.
Set value to 0 to disable all output. Additionally, you can compile this library with the macro NDEBUG defined, which will disable all output and skip checks to "verbose" altogether in the compiled code.
[in] | value | whether (1) or not (0) the program should output error messages and info to stderr. |
Definition at line 20 of file zb_serial.c.
|
static |
Definition at line 18 of file zb_serial.c.
Referenced by zb_set_verbose().