Core Serial Library in C  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
zb_serial.h
Go to the documentation of this file.
1 
22 #if !defined(ZB_SERIAL_H)
23 #define ZB_SERIAL_H
24 
25 #if defined(__cplusplus)
26 extern "C"{
27 #endif /* if defined(__cplusplus) */
28 
29 #include "z_common.h"
30 
52 int zb_connect(z_port *port, const char *port_name);
53 
60 int zb_disconnect(z_port port);
61 
79 int zb_send(z_port port, const uint8_t *command);
80 
107 int zb_receive(z_port port, uint8_t *destination);
108 
128 int zb_encode(uint8_t *destination, uint8_t device_number,
129  uint8_t command_number, int32_t data);
130 
152 int zb_decode(int32_t *destination, const uint8_t *reply);
153 
175 int zb_drain(z_port port);
176 
197 int zb_set_timeout(z_port port, int milliseconds);
198 
208 void zb_set_verbose(int value);
209 
210 #if defined(__cplusplus)
211 }
212 #endif /* if defined(__cplusplus) */
213 
214 #endif /* if !defined(ZB_SERIAL_H) */
215 
int zb_drain(z_port port)
Flushes all input received but not yet read, and attempts to drain all input that would be incoming...
int zb_disconnect(z_port port)
Gracefully closes a connection.
int zb_set_timeout(z_port port, int milliseconds)
Change the duration zb_receive() will wait before timing out and returning without having read anythi...
int zb_send(z_port port, const uint8_t *command)
Sends a command to a serial port.
int zb_connect(z_port *port, const char *port_name)
Connect to a serial port specified by port_name.
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.
Defines a few things that all of the serial API has in common.
void zb_set_verbose(int value)
Sets whether errors and extra info are reported to stderr.
int zb_receive(z_port port, uint8_t *destination)
Receives a message from the serial port.
int zb_decode(int32_t *destination, const uint8_t *reply)
Decodes the last 4 bytes of a 6-byte (complete) reply.
HANDLE z_port
A type to represent a port connected to one or more Zaber devices.
Definition: z_common.h:31