|
|
// SOPSUYSI_RS232.h
|
|
|
#include "rs232config.h"
|
|
|
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
#include <windows.h>
|
|
|
#define badPortValue INVALID_HANDLE_VALUE
|
|
|
typedef HANDLE rs232port_t;
|
|
|
typedef DWORD rs232speed_t;
|
|
|
typedef enum {rs232OneStop=ONESTOPBIT,rs232One5Stop=ONE5STOPBITS,rs232TwoStop=TWOSTOPBITS}rs232stop;
|
|
|
typedef enum {rs232parityNo=NOPARITY,rs232parityOdd=ODDPARITY,rs232parityEven=EVENPARITY}rs232parity;
|
|
|
#else
|
|
|
#ifdef HAVE_TERMIOS_H
|
|
|
#include <termios.h>
|
|
|
#define badPortValue -1
|
|
|
typedef int rs232port_t;
|
|
|
typedef speed_t rs232speed_t;
|
|
|
typedef enum {rs232OneStop=1,rs232One5Stop=2,rs232TwoStop=2}rs232stop;
|
|
|
typedef enum {rs232parityNo=(~PARENB),rs232parityOdd=(PARENB|PARODD),rs232parityEven=(PARENB|~PARODD)}rs232parity;
|
|
|
#endif
|
|
|
#endif
|
|
|
#ifdef __cplusplus
|
|
|
#define rs232extern extern "C"
|
|
|
#else
|
|
|
#define rs232extern extern
|
|
|
#endif
|
|
|
rs232extern rs232port_t rs232open(char* psPortName);
|
|
|
rs232extern int rs232close(rs232port_t fd);
|
|
|
rs232extern int rs232setup(rs232port_t fd, int ChSize, int BaudeRate, rs232parity Parity, rs232stop NbStop);
|
|
|
rs232extern int rs232write(rs232port_t fd,char *psWrite, int WriteBufferSize);
|
|
|
rs232extern int rs232read(rs232port_t fd,char *psRead, int ReadBufferSize);
|
|
|
rs232extern int rs232setparity(rs232port_t fd, rs232parity Parity);
|
|
|
rs232extern int rs232setnbstop(rs232port_t fd, rs232stop NbStop);
|
|
|
rs232extern int rs232setcsize(rs232port_t fd, int ChSize);
|
|
|
rs232extern int rs232setbaudrate(rs232port_t fd, int baudrate);
|
|
|
|