tmr_serial_transport.h
Go to the documentation of this file.
00001 #ifndef _TMR_SERIAL_TRANSPORT_H
00002 #define _TMR_SERIAL_TRANSPORT_H
00003 
00010 /*
00011  * Copyright (c) 2009 ThingMagic, Inc.
00012  *
00013  * Permission is hereby granted, free of charge, to any person obtaining a copy
00014  * of this software and associated documentation files (the "Software"), to deal
00015  * in the Software without restriction, including without limitation the rights
00016  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00017  * copies of the Software, and to permit persons to whom the Software is
00018  * furnished to do so, subject to the following conditions:
00019  *
00020  * The above copyright notice and this permission notice shall be included in
00021  * all copies or substantial portions of the Software.
00022  * 
00023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00024  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00025  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00026  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00027  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00028  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00029  * THE SOFTWARE.
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 /* TMR_ENABLE_SERIAL_TRANSPORT_NATIVE */
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 /* _TMR_SERIAL_TRANSPORT_H */


thingmagic_rfid
Author(s): Brian Bingham
autogenerated on Thu May 16 2019 03:01:24