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 00033 /* Stub implementation of serial transport layer routines. */ 00034 00035 static TMR_Status 00036 s_open(TMR_SR_SerialTransport *this) 00037 { 00038 00039 /* This routine should open the serial connection */ 00040 00041 return TMR_ERROR_UNIMPLEMENTED; 00042 } 00043 00044 00045 static TMR_Status 00046 s_sendBytes(TMR_SR_SerialTransport *this, uint32_t length, 00047 uint8_t* message, const uint32_t timeoutMs) 00048 { 00049 00050 /* This routine should send length bytes, pointed to by message on 00051 * the serial connection. If the transmission does not complete in 00052 * timeoutMs milliseconds, it should return TMR_ERROR_TIMEOUT. 00053 */ 00054 00055 return TMR_ERROR_UNIMPLEMENTED; 00056 } 00057 00058 00059 static TMR_Status 00060 s_receiveBytes(TMR_SR_SerialTransport *this, uint32_t length, 00061 uint32_t* messageLength, uint8_t* message, const uint32_t timeoutMs) 00062 { 00063 00064 /* This routine should receive exactly length bytes on the serial 00065 * connection and store them into the memory pointed to by 00066 * message. If the required number of bytes are note received in 00067 * timeoutMs milliseconds, it should return TMR_ERROR_TIMEOUT. 00068 */ 00069 00070 return TMR_ERROR_UNIMPLEMENTED; 00071 } 00072 00073 00074 static TMR_Status 00075 s_setBaudRate(TMR_SR_SerialTransport *this, uint32_t rate) 00076 { 00077 00078 /* This routine should change the baud rate of the serial connection 00079 * to the specified rate, or return TMR_ERROR_INVALID if the rate is 00080 * not supported. 00081 */ 00082 00083 return TMR_ERROR_UNIMPLEMENTED; 00084 } 00085 00086 00087 static TMR_Status 00088 s_shutdown(TMR_SR_SerialTransport *this) 00089 { 00090 00091 /* This routine should close the serial connection and release any 00092 * acquired resources. 00093 */ 00094 00095 return TMR_ERROR_UNIMPLEMENTED; 00096 } 00097 00098 static TMR_Status 00099 s_flush(TMR_SR_SerialTransport *this) 00100 { 00101 00102 /* This routine should empty any input or output buffers in the 00103 * communication channel. If there are no such buffers, it may do 00104 * nothing. 00105 */ 00106 00107 return TMR_ERROR_UNIMPLEMENTED; 00108 } 00109 00110 00111 00112 /* This function is not part of the API as such. This is for 00113 * application code to call to fill in the transport object before 00114 * initializing the reader object itself, as in the following code: 00115 * 00116 * TMR_Reader reader; 00117 * 00118 * TMR_SR_SerialTransportDummyInit(&reader.u.serialReader.transport, myArgs); 00119 * TMR_SR_SerialReader_init(&reader); 00120 * 00121 * The initialization should not actually open a communication channel 00122 * or acquire other communication resources at this time. 00123 */ 00124 TMR_Status 00125 TMR_SR_SerialTransportDummyInit(TMR_SR_SerialTransport *transport, 00126 TMR_SR_SerialPortNativeContext *context, void *other) 00127 { 00128 00129 /* Each of the callback functions will be passed the transport 00130 * pointer, and they can use the "cookie" member of the transport 00131 * structure to store the information specific to the transport, 00132 * such as a file handle or the memory address of the FIFO. 00133 */ 00134 transport->cookie = other; 00135 00136 transport->open = s_open; 00137 transport->sendBytes = s_sendBytes; 00138 transport->receiveBytes = s_receiveBytes; 00139 transport->setBaudRate = s_setBaudRate; 00140 transport->shutdown = s_shutdown; 00141 transport->flush = s_flush; 00142 00143 return TMR_SUCCESS; 00144 } 00145 00153 TMR_Status 00154 TMR_SR_SerialTransportNativeInit(TMR_SR_SerialTransport *transport, 00155 TMR_SR_SerialPortNativeContext *context, 00156 const char *device) 00157 { 00158 return TMR_SUCCESS; 00159 } 00160