DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/serialport/libserial.h
00001 /*
00002  *  Copyright (C) 2002-2020  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License along
00015  *  with this program; if not, write to the Free Software Foundation, Inc.,
00016  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include <string.h>
00020 
00021 typedef struct _COMPORT *COMPORT;
00022 
00023 bool SERIAL_open(const char* portname, COMPORT* port);
00024 void SERIAL_close(COMPORT port);
00025 void SERIAL_getErrorString(char* buffer, size_t length);
00026 
00027 #define SERIAL_1STOP 1
00028 #define SERIAL_2STOP 2
00029 #define SERIAL_15STOP 0
00030 
00031 // parity: n, o, e, m, s
00032 
00033 bool SERIAL_setCommParameters(COMPORT port,
00034                         int baudrate, char parity, int stopbits, int length);
00035 
00036 void SERIAL_setDTR(COMPORT port, bool value);
00037 void SERIAL_setRTS(COMPORT port, bool value);
00038 void SERIAL_setBREAK(COMPORT port, bool value);
00039 
00040 #define SERIAL_CTS 0x10
00041 #define SERIAL_DSR 0x20
00042 #define SERIAL_RI 0x40
00043 #define SERIAL_CD 0x80
00044 
00045 int SERIAL_getmodemstatus(COMPORT port);
00046 bool SERIAL_setmodemcontrol(COMPORT port, int flags);
00047 
00048 bool SERIAL_sendchar(COMPORT port, char data);
00049 
00050 // 0-7 char data, higher=flags
00051 #define SERIAL_BREAK_ERR 0x10
00052 #define SERIAL_FRAMING_ERR 0x08
00053 #define SERIAL_PARITY_ERR 0x04
00054 #define SERIAL_OVERRUN_ERR 0x02
00055 
00056 int SERIAL_getextchar(COMPORT port);