#ifndef __SERIAL_PORT_SERIAL_OVER_LAN__ #define __SERIAL_PORT_SERIAL_OVER_LAN__ /* #!/bin/bash # open virtual serial port socat pty,link=$HOME/vmodem0,waitslave tcp:10.73.1.71:23 & # run the program ./testcomms.py # kill socat afterwards killall socat https://blog.febo.com/?p=457 https://stackoverflow.com/questions/484740/converting-serial-port-data-to-tcp-ip-in-a-linux-environment http://www.dest-unreach.org/socat/doc/socat-ttyovertcp.txt */ #include #include #include #include // File control definitions #include #ifdef __linux__ #include #include #include #include #else #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS #define _WINSOCK_DEPRECATED_NO_WARNINGS #endif #include #endif #ifdef DEBUG //#define _DEBUG_SOL_COMMUNICATION_ #endif #include "../../data/transport/transportSocket.h" typedef enum E_SOL_TYPE{ SOL_UDP_CLIENT = 0, SOL_TCP_CLIENT = 1, SOL_UDP_SERVER = 2, SOL_TCP_SERVER = 3 }SOL_TYPE; /** * TODO: Add class description * * @author gagua */ class serialSOL: public transportSocket { private: basicLogCollection *m_pLog; SOL_TYPE m_eSolType; bool m_bInitComplete; #ifdef __linux__ int m_nSocketFD; struct sockaddr_in m_sServerAddr; struct sockaddr_in m_sClientAddr; #else WSADATA wsaData; SOCKET m_sSocket; SOCKADDR_IN ReceiverAddr; int SelectTiming; #endif protected: int sendBlock( unsigned char *Data, int DataSize ); int recptBlock( unsigned char *Buffer, int *BufferLength ); public: explicit serialSOL( SOL_TYPE t ); virtual ~serialSOL(); bool create( CSTR address, uint16_t port, int Speed ); }; #endif