serial_transport_ios.c
Go to the documentation of this file.
00001 
00009 /*
00010  * Copyright (c) 2010 ThingMagic, Inc.
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a copy
00013  * of this software and associated documentation files (the "Software"), to deal
00014  * in the Software without restriction, including without limitation the rights
00015  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00016  * copies of the Software, and to permit persons to whom the Software is
00017  * furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included in
00020  * all copies or substantial portions of the Software.
00021  * 
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00023  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00025  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00027  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00028  * THE SOFTWARE.
00029  */
00030 
00031 #include "tm_reader.h"
00032 #include <stdio.h>
00033 #include "MercuryApi.h"
00034 
00035 /* Stub implementation of serial transport layer routines. */
00036 
00037 static TMR_Status
00038 s_open(TMR_SR_SerialTransport *this)
00039 {
00040 
00041     printf("s_open");
00042   /* This routine should open the serial connection */
00043     return RDRscMgrOpen(this);
00044 }
00045 
00046 
00047 static TMR_Status
00048 s_sendBytes(TMR_SR_SerialTransport *this, uint32_t length, 
00049                 uint8_t* message, const uint32_t timeoutMs)
00050 {
00051 
00052   /* This routine should send length bytes, pointed to by message on
00053    * the serial connection. If the transmission does not complete in
00054    * timeoutMs milliseconds, it should return TMR_ERROR_TIMEOUT.
00055    */
00056 
00057   return RDRscMgrSendBytes(this, length, message, timeoutMs);
00058 }
00059 
00060 
00061 static TMR_Status
00062 s_receiveBytes(TMR_SR_SerialTransport *this, uint32_t length, 
00063                    uint32_t* messageLength, uint8_t* message, const uint32_t timeoutMs)
00064 {
00065 
00066   /* This routine should receive exactly length bytes on the serial
00067    * connection and store them into the memory pointed to by
00068    * message. If the required number of bytes are note received in
00069    * timeoutMs milliseconds, it should return TMR_ERROR_TIMEOUT.
00070    */
00071 
00072   return RDRscMgrReceiveBytes(this, length, messageLength, message, timeoutMs);
00073 }
00074 
00075 
00076 static TMR_Status
00077 s_setBaudRate(TMR_SR_SerialTransport *this, uint32_t rate)
00078 {
00079 
00080   /* This routine should change the baud rate of the serial connection
00081    * to the specified rate, or return TMR_ERROR_INVALID if the rate is
00082    * not supported.
00083    */
00084 
00085   return setRDRscMgrBaudRate(this, rate);
00086 }
00087 
00088 
00089 static TMR_Status
00090 s_shutdown(TMR_SR_SerialTransport *this)
00091 {
00092 
00093   /* This routine should close the serial connection and release any
00094    * acquired resources.
00095    */
00096 
00097   return RDRscMgrshutdown(this);
00098 }
00099 
00100 static TMR_Status
00101 s_flush(TMR_SR_SerialTransport *this)
00102 {
00103 
00104   /* This routine should empty any input or output buffers in the
00105    * communication channel. If there are no such buffers, it may do
00106    * nothing.
00107    */
00108 
00109   return RDRscMgrFlush(this);
00110 }
00111 
00112 
00113 
00114 /* This function is not part of the API as such. This is for
00115  * application code to call to fill in the transport object before
00116  * initializing the reader object itself, as in the following code:
00117  * 
00118  * TMR_Reader reader;
00119  *
00120  * TMR_SR_SerialTransportDummyInit(&reader.u.serialReader.transport, myArgs);
00121  * TMR_SR_SerialReader_init(&reader);
00122  *
00123  * The initialization should not actually open a communication channel
00124  * or acquire other communication resources at this time.
00125  */
00126 TMR_Status
00127 TMR_SR_SerialTransportNativeInit(TMR_SR_SerialTransport *transport,
00128                                                                 TMR_SR_SerialPortNativeContext *context, const char *device)
00129 {
00130 
00131   /* Each of the callback functions will be passed the transport
00132    * pointer, and they can use the "cookie" member of the transport
00133    * structure to store the information specific to the transport,
00134    * such as a file handle or the memory address of the FIFO.
00135    */
00136     
00137   transport->cookie = context;
00138 
00139   transport->open = s_open;
00140   transport->sendBytes = s_sendBytes;
00141   transport->receiveBytes = s_receiveBytes;
00142   transport->setBaudRate = s_setBaudRate;
00143   transport->shutdown = s_shutdown;
00144   transport->flush = s_flush;
00145 
00146   return TMR_SUCCESS;
00147 }
00148 
00156 //TMR_Status
00157 //TMR_SR_SerialTransportNativeInit(TMR_SR_SerialTransport *transport,
00158 //                                 TMR_SR_SerialPortNativeContext *context,
00159 //                                 const char *device)
00160 //{
00161 //  return TMR_SUCCESS;
00162 //}
00163 


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