- /**
- * Redirection simple d'un port COM(RS232) vers la sortie standard sous Windows.
- *
- * @filename redir.cpp
- * @version 1.1
- */
- #include <cstdio>
-
- #include <COMPort.h>
-
- /**
- * Macro de transformation du texte pour les vesrions de windows UNICODE
- * i.e: XP, 2003, Vista
- */
- #ifdef UNICODE
- #define _T(x) (L##x)
- #else
- #define _T(x) (x)
- #endif
-
- void usage(int argc, const char * const * argv)
- {
- ::printf("Usage: %s <port>\nWhere <port> is a COM port name,"
- "from COM1 to COM15, depending on your system hardware.\n", argv[0]);
- }
-
- int main(int argc, const char * const * argv)
- {
- COMPort pCom;
- CHAR lpBuff[1024];
-
- if(argc < 2)
- {
- usage(argc, argv);
- return 0;
- }
-
- pCom.open(argv[1]);
-
- if(!(pCom.isOpened()))
- {
- ::printf("Opening error\n");
- return 0;
- }
- pCom.setTimeOut(1, 1, 1);
- pCom.setCommunication(CBR_19200, 8, NOPARITY, ONESTOPBIT);
- pCom.setBufferSize(4096, 128);
-
- for(;;)
- {
- if(pCom.read(lpBuff, sizeof(*lpBuff), 1023))
- printf("%s", lpBuff);
- }
-
- return 0;
- }
/**
* Redirection simple d'un port COM(RS232) vers la sortie standard sous Windows.
*
* @filename redir.cpp
* @version 1.1
*/
#include <cstdio>
#include <COMPort.h>
/**
* Macro de transformation du texte pour les vesrions de windows UNICODE
* i.e: XP, 2003, Vista
*/
#ifdef UNICODE
#define _T(x) (L##x)
#else
#define _T(x) (x)
#endif
void usage(int argc, const char * const * argv)
{
::printf("Usage: %s <port>\nWhere <port> is a COM port name,"
"from COM1 to COM15, depending on your system hardware.\n", argv[0]);
}
int main(int argc, const char * const * argv)
{
COMPort pCom;
CHAR lpBuff[1024];
if(argc < 2)
{
usage(argc, argv);
return 0;
}
pCom.open(argv[1]);
if(!(pCom.isOpened()))
{
::printf("Opening error\n");
return 0;
}
pCom.setTimeOut(1, 1, 1);
pCom.setCommunication(CBR_19200, 8, NOPARITY, ONESTOPBIT);
pCom.setBufferSize(4096, 128);
for(;;)
{
if(pCom.read(lpBuff, sizeof(*lpBuff), 1023))
printf("%s", lpBuff);
}
return 0;
}