You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h> // File control definitions
#include <sys/types.h>
#ifdef __linux__
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#else
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#include <winsock2.h>
#endif
#ifdef DEBUG
//#define _DEBUG_SOL_COMMUNICATION_
#endif
#include "../../data/transport/transportSocket.h"
/**
* TODO: Add class description * * @author gagua */class serialSOL: public transportSocket { private: basicLogCollection *m_pLog; SOL_PORT_SETTINGS m_sPortSettings; 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 ); explicit serialSOL( SOL_PORT_SETTINGS *PortSettings ); virtual ~serialSOL(); bool create( CSTR address, uint16_t port, int Speed );};
#endif
|