Note that there are some explanatory texts on larger screens.

plurals
  1. PORFID Serial Port Time Out When Reading Data
    primarykey
    data
    text
    <p>thanks for taking the time to look at my issue! </p> <p>I have a Texas Instruments S4100 RFID scanner. I am attempting to simply read the ID of the tags I swipe over the scanner with a C++ console app. I've been pulling my hair out since this is the first time I've ever worked with serial ports. I found out quite a bit about the issue. I first used the createfile function and then the ReadFile function. I am extremely confident I opened the port correctly as the functions returned true. And when I attempted to open a program I know connects to the device (the demo program that came with the scanner) it says the port is already in use. </p> <p>Since I could not get data from that method I switched gears and found a .dll from TI itself. The FeComm.dll .. I found online documentation for the .dll here:</p> <p><a href="http://www.ti.com/rfid/docs/manuals/refmanuals/S6000ProgramLibraryFECOM.pdf" rel="nofollow">http://www.ti.com/rfid/docs/manuals/refmanuals/S6000ProgramLibraryFECOM.pdf</a></p> <p>Again I am able to open the port but now I am getting a timeout error even when I swipe the card over the device! In the code below you will see that I manually set the timeout to 8000ms (yes I was pulling at straws haha) but still nothing! Am I missing something really obvious? Perhaps I have to send a command to the device first to "start" it up? The demo program had no source code and I can't find anything that works online. Please offer me a clue as to what is going on! Thanks in advance =)</p> <p>Here is my main() function:</p> <pre><code>#include "stdafx.h" #include &lt;windows.h&gt; #include "FeCom.h" #include "FeComDef.h" #include &lt;windows.h&gt; #include &lt;tchar.h&gt; #include &lt;assert.h&gt; #include &lt;stdio.h&gt; #include &lt;iomanip&gt; #include &lt;iostream&gt; using namespace std; int main(int argc, char* argv[]) { int iRecProtLen; char cPortNr[4]; char cValue[128]; char* para = "Timeout"; char* toValue = "8000"; _itoa( 1, cPortNr, 10 ); // Convert Integer to Char UCHAR cRecBuf[256]; // Buffer size may have to be matched to the receive data int handle = FECOM_OpenPort( cPortNr ); // COM:1 is opened if( handle &lt; 0 ) { // Code in the event of an error cout&lt;&lt;"Error opening the port"&lt;&lt;endl; } else { // Communication via COM:1; if successful, the receive data are located in cRecBuf FECOM_SetPortPara(handle, para, toValue); if(!FECOM_GetPortPara(handle, para, cValue)) { // code here for displaying the COM parameter cout&lt;&lt;"TimeOut Parameter: "&lt;&lt;cValue&lt;&lt;endl; } iRecProtLen = FECOM_Receive( handle, cRecBuf, 256 ); // If this is true then the function has thrown an error if( iRecProtLen &lt; 0 ) { // Communication erorr or buffer overflow if( iRecProtLen == FECOM_ERR_OVL_RECBUF ) { // Buffer overflow: data in RecBuf are valid receive data cout&lt;&lt;"Buffer Overflow"&lt;&lt;endl; } //cout&lt;&lt;"FECOM ERR OVL RECBUF: "&lt;&lt;FECOM_ERR_OVL_RECBUF&lt;&lt;endl; } cout&lt;&lt;"IRECTPROTLEN: "&lt;&lt;iRecProtLen&lt;&lt;endl; cout&lt;&lt;"Return from Recieve: "&lt;&lt;cRecBuf&lt;&lt;endl; } return 0; } </code></pre> <p>Here is the FeCom.h file.</p> <pre><code>/*------------------------------------------------------- | | | FECOM.h | | | --------------------------------------------------------- Operation Systems : Windows 9x/ME/NT/2000 This file contains the constants, datatypes and function declartions of FECOM.DLL */ #ifndef _FECOM_INCLUDE_H #define _FECOM_INCLUDE_H #ifdef FECOMDLL #define DLL_EXT_FUNC __declspec(dllexport) __stdcall #else #define DLL_EXT_FUNC __declspec(dllimport) __stdcall #endif #ifdef __cplusplus extern "C" { #endif // ##################################################### // FECOM constants // ##################################################### // defines for uiFlag in FECOM_EVENT_INIT #define FECOM_THREAD_ID 1 #define FECOM_WND_HWND 2 #define FECOM_CALLBACK 3 #define FECOM_EVENT 4 // defines for uiUse in FECOM_EVENT_INIT #define FECOM_CTS_EVENT 1 #define FECOM_DCD_EVENT 2 #define FECOM_DSR_EVENT 3 #define FECOM_RTS_EVENT 4 #define FECOM_DTR_EVENT 5 // ##################################################### // FECOM structures // ##################################################### // structure for transfering thread-IDs, message-handles or callbacks typedef struct _FECOM_EVENT_INIT { UINT uiUse; // defines the event (e.g. FECOM_CTS_EVENT) UINT uiMsg; // message code used with dwThreadID and hwndWnd (e.g. WM_USER_xyz) UINT uiFlag; // specifies the use of the union (e.g. FECOM_WND_HWND) union { DWORD dwThreadID; // for thread-ID HWND hwndWnd; // for window-handle void (*cbFct)(int, int); // for callback-function HANDLE hEvent; // for event-handle #ifdef __cplusplus }; #else }Method; #endif } FECOM_EVENT_INIT; // ##################################################### // FECOM functions // ##################################################### // miscellaneous functions void DLL_EXT_FUNC FECOM_GetDLLVersion( char* cVersion ); int DLL_EXT_FUNC FECOM_GetErrorText( int iErrorCode, char* cErrorText ); int DLL_EXT_FUNC FECOM_GetLastError( int iPortHnd, int* iErrorCode, char* cErrorText ); // functions for event notification int DLL_EXT_FUNC FECOM_AddEventHandler(int iPortHnd, FECOM_EVENT_INIT* pInit); int DLL_EXT_FUNC FECOM_DelEventHandler(int iPortHnd, FECOM_EVENT_INIT* pInit); // port functions int DLL_EXT_FUNC FECOM_OpenPort( char* cPortNr ); int DLL_EXT_FUNC FECOM_ClosePort( int iPortHnd ); int DLL_EXT_FUNC FECOM_GetPortList( int iNext ); int DLL_EXT_FUNC FECOM_GetPortPara( int iPortHnd, char* cPara, char* cValue ); int DLL_EXT_FUNC FECOM_SetPortPara( int iPortHnd, char* cPara, char* cValue ); int DLL_EXT_FUNC FECOM_DoPortCmd( int iPortHnd, char* cCmd, char* cValue ); int DLL_EXT_FUNC FECOM_GetPortHnd( char* cPortNr ); // communication function int DLL_EXT_FUNC FECOM_Transceive( int iPortHnd, UCHAR* cSendProt, int iSendLen, UCHAR* cRecProt, int iRecLen ); int DLL_EXT_FUNC FECOM_Transmit( int iPortHnd, UCHAR* cSendProt, int iSendLen ); int DLL_EXT_FUNC FECOM_Receive( int iPortHnd, UCHAR* cRecProt, int iRecLen ); #undef DLL_EXT_FUNC #ifdef __cplusplus } #endif // ##################################################### // typedefs of DLL-functions for explicite loading // ##################################################### // miscellaneous functions typedef void (CALLBACK* LPFN_FECOM_GET_DLL_VERSION)(char*); typedef int (CALLBACK* LPFN_FECOM_GET_ERROR_TEXT)(int, char*); typedef int (CALLBACK* LPFN_FECOM_GET_LAST_ERROR)(int, int*, char*); // functions for event notification typedef int (CALLBACK* LPFN_FECOM_ADD_EVENT_HANDLER)(FECOM_EVENT_INIT*); typedef int (CALLBACK* LPFN_FECOM_DEL_EVENT_HANDLER)(FECOM_EVENT_INIT*); // port functions typedef int (CALLBACK* LPFN_FECOM_OPEN_PORT)(long); typedef int (CALLBACK* LPFN_FECOM_CLOSE_PORT)(int); typedef int (CALLBACK* LPFN_FECOM_GET_PORT_LIST)(int); typedef int (CALLBACK* LPFN_FECOM_GET_PORT_PARA)(int, char*, char*); typedef int (CALLBACK* LPFN_FECOM_SET_PORT_PARA)(int, char*, char*); typedef int (CALLBACK* LPFN_FECOM_DO_PORT_CMD)(int, char*, char*); typedef int (CALLBACK* LPFN_FECOM_GET_PORT_HND)(char*); // communication function typedef int (CALLBACK* LPFN_FECOM_TRANSCEIVE)(int, UCHAR*, int, UCHAR*, int); typedef int (CALLBACK* LPFN_FECOM_TRANSMIT)(int, UCHAR*, int); typedef int (CALLBACK* LPFN_FECOM_RECEIVE)(int, UCHAR*, int); #endif // _FECOM_INCLUDE_H </code></pre> <p>Here is the FeComDef.h file:</p> <pre><code>/*------------------------------------------------------- | | | FECOMDef.h | | | --------------------------------------------------------- Operation Systems : Windows 9x/ME/NT/2000 This file contains the error codes for FECOM.DLL */ #ifndef _FECOMDEF_H_ #define _FECOMDEF_H_ // FECOM error codes // common errors #define FECOM_ERR_NEWPORT_FAILURE -1000 #define FECOM_ERR_EMPTY_LIST -1001 #define FECOM_ERR_POINTER_IS_NULL -1002 #define FECOM_ERR_NO_MEMORY -1003 #define FECOM_ERR_UNSUPPORTED_HARDWARE -1004 // new in V2.00.00 // error while open the port #define FECOM_ERR_NO_PORT -1010 #define FECOM_ERR_NO_CONNECT -1011 #define FECOM_ERR_LINK_ID -1012 #define FECOM_ERR_PORT_IS_OPEN -1013 // new in V2.00.00 // handle errors #define FECOM_ERR_UNKNOWN_HND -1020 #define FECOM_ERR_HND_IS_NULL -1021 #define FECOM_ERR_HND_IS_NEGATIVE -1022 #define FECOM_ERR_NO_HND_FOUND -1023 // communication errors #define FECOM_ERR_TIMEOUT -1030 #define FECOM_ERR_NO_SENDPROTOCOL -1031 #define FECOM_ERR_RECEIVE_PROCESS -1032 // renamed in V2.00.00 #define FECOM_ERR_INIT_COMM_PROCESS -1033 // new in V2.00.00 #define FECOM_ERR_FLUSH_INPUT_BUFFER -1034 // new in V2.00.00 #define FECOM_ERR_FLUSH_OUTPUT_BUFFER -1035 // new in V2.00.00 #define FECOM_ERR_CHANGE_PORT_PARA -1036 // new in V2.00.00 #define FECOM_ERR_TRANSMIT_PROCESS -1037 // new in V2.00.00 // parameter errors #define FECOM_ERR_UNKNOWN_PARAMETER -1050 #define FECOM_ERR_PARAMETER_OUT_OF_RANGE -1051 #define FECOM_ERR_ODD_PARAMETERSTRING -1052 #define FECOM_ERR_PORTNR_OUT_OF_RANGE -1053 #define FECOM_ERR_UNKNOWN_ERRORCODE -1054 // receive buffer overflow #define FECOM_ERR_OVL_RECBUF -1070 #endif _FECOMDEF_H_ </code></pre> <p>If you run the code iRecProtLen = -1030 which according to the documentation is a timeout error. And yes I'm swiping the card over the device while the program runs ;) </p> <p>I'm not sold on the idea of using these functions. If someone can offer me a solution that they know about I'd be fine with that or if you need more information please ask. I just don't know what the problem is. The port opens but no data read. Really confusing to me. I hope you guys can help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload