36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
// Socket shim — provides rs232-compatible API backed by TCP sockets
|
|
// Used by the Linux proxy to reuse the packet and secLink layers.
|
|
|
|
#ifndef SOCKSHIM_H
|
|
#define SOCKSHIM_H
|
|
|
|
// Block the real rs232.h from being included
|
|
#define RS232_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
// rs232-compatible constants (subset used by packet and secLink)
|
|
#define RS232_COM1 0
|
|
#define RS232_COM2 1
|
|
#define RS232_COM3 2
|
|
#define RS232_COM4 3
|
|
|
|
#define RS232_HANDSHAKE_NONE 0
|
|
|
|
#define RS232_SUCCESS 0
|
|
#define RS232_ERR_NOT_OPEN -2
|
|
#define RS232_ERR_INVALID_PORT -5
|
|
|
|
|
|
// Associate a socket fd with a COM index. Must be called before
|
|
// rs232Open/pktOpen/secLinkOpen. Sets the socket to non-blocking.
|
|
void sockShimSetFd(int com, int fd);
|
|
|
|
// rs232-compatible functions backed by TCP sockets
|
|
int rs232Close(int com);
|
|
int rs232Open(int com, int32_t bps, int dataBits, char parity, int stopBits, int handshake);
|
|
int rs232Read(int com, char *data, int len);
|
|
int rs232Write(int com, const char *data, int len);
|
|
|
|
#endif
|