Go to the documentation of this file.00001 #ifndef _TMR_SERIAL_TRANSPORT_H
00002 #define _TMR_SERIAL_TRANSPORT_H
00003
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036 #ifdef TMR_ENABLE_SERIAL_TRANSPORT_LLRP
00037 #include <sys/types.h>
00038 #include <sys/socket.h>
00039 #endif
00040
00041 #ifdef WIN32
00042 #include <windows.h>
00043 #endif
00044
00045 #ifdef OSDEP_SERIAL_INCLUDE
00046 #include "osdep_serial_transport.h"
00047 #endif
00048
00049 #ifndef PLATFORM_HANDLE
00050 # ifdef WIN32
00051 # define PLATFORM_HANDLE HANDLE
00052 # else
00053 #if defined(ARDUINO) || defined(FREERTOS_USED)
00054 # define PLATFORM_HANDLE void*
00055 # else
00056 # define PLATFORM_HANDLE int
00057 # endif
00058 # endif
00059 #endif
00060 typedef struct TMR_SR_SerialTransport TMR_SR_SerialTransport;
00073 struct TMR_SR_SerialTransport
00074 {
00076 void *cookie;
00077
00086 TMR_Status (*open)(TMR_SR_SerialTransport *);
00087
00098 TMR_Status (*sendBytes)(TMR_SR_SerialTransport *, uint32_t length,
00099 uint8_t* message, const uint32_t timeoutMs);
00100
00113 TMR_Status (*receiveBytes)(TMR_SR_SerialTransport *, uint32_t length,
00114 uint32_t *messageLength, uint8_t* message, const uint32_t timeoutMs);
00122 TMR_Status (*setBaudRate)(TMR_SR_SerialTransport *, uint32_t rate);
00123
00131 TMR_Status (*shutdown)(TMR_SR_SerialTransport *);
00132
00139 TMR_Status (*flush)(TMR_SR_SerialTransport *);
00140 };
00141
00142 #ifdef TMR_ENABLE_SERIAL_TRANSPORT_NATIVE
00143
00146 typedef struct TMR_SR_SerialPortNativeContext
00147 {
00150 PLATFORM_HANDLE handle;
00152 char devicename[TMR_MAX_READER_NAME_LENGTH];
00153 } TMR_SR_SerialPortNativeContext;
00154 #endif
00155
00156 #ifdef TMR_ENABLE_SERIAL_TRANSPORT_LLRP
00157
00161 typedef struct TMR_SR_LlrpEapiTransportContext
00162 {
00165 struct sockaddr_storage addr;
00167 socklen_t addrlen;
00169 bool powerCycleAtOpen;
00171 int socket;
00173 int sequenceId;
00175 uint8_t buf[270];
00177 uint16_t bufstart, buflen;
00178 } TMR_SR_LlrpEapiTransportContext;
00179 #endif
00180
00181 #ifdef TMR_ENABLE_SERIAL_TRANSPORT_NATIVE
00182
00189 #ifdef WIN32
00190 __declspec(dllexport)
00191 #endif
00192 TMR_Status TMR_SR_SerialTransportNativeInit(TMR_SR_SerialTransport *transport,
00193 TMR_SR_SerialPortNativeContext *context,
00194 const char *device);
00195 #ifdef WIN32
00196 __declspec(dllexport)
00197 #endif
00198 TMR_Status TMR_SR_SerialTransportTcpNativeInit(TMR_SR_SerialTransport *transport,
00199 TMR_SR_SerialPortNativeContext *context,
00200 const char *device);
00201 #endif
00202
00203 #ifdef TMR_ENABLE_SERIAL_TRANSPORT_LLRP
00204
00214 TMR_Status TMR_SR_LlrpEapiTransportInit(TMR_SR_SerialTransport *transport,
00215 TMR_SR_LlrpEapiTransportContext *context,
00216 const char *host, int port,
00217 bool powerCycleAtOpen);
00218
00223 TMR_Status TMR_LlrpEapiPowerCycle(TMR_SR_SerialTransport *this);
00224 #endif
00225
00226 #ifdef __cplusplus
00227 }
00228 #endif
00229
00230 #endif