Commit 5a19d8c2 authored by Teuniz's avatar Teuniz

Added function to check for status of "RING"

 Added 921600, 1500000, 2000000, 3000000 baud rates for windows
 Extended comport range to COM32 for windows
parent 2aa0dc0c
......@@ -2,7 +2,7 @@
#
# Author: Teunis van Beelen
#
# email: [email protected]gmail.com
# email: [email protected]protonmail.com
#
#
......
......@@ -2,10 +2,10 @@
Library: RS-232
Author: Teunis van Beelen
Url: http://www.teuniz.net/RS-232/
E-mail: [email protected]gmail.com
E-mail: [email protected]protonmail.com
License: GPLv3
Last revision: November 22, 2017
Last revision: May 20, 2019
......@@ -76,6 +76,10 @@ void RS232_disableRTS(int comport_number)
Sets the RTS line low (non active state).
int RS232_IsRINGEnabled(int comport_number)
Checks the status of the RING-pin. Returns 1 when the the RING line is high (active state), otherwise 0.
int RS232_IsDSREnabled(int comport_number)
Checks the status of the DSR-pin. Returns 1 when the the DSR line is high (active state), otherwise 0.
......@@ -128,40 +132,39 @@ Note: Traditional (on-board) UART's usually have a speed limit of max. 115200 ba
List of comport numbers, possible baudrates and modes:
Linux windows
0 ttyS0 COM1
1 ttyS1 COM2
2 ttyS2 COM3
3 ttyS3 COM4
4 ttyS4 COM5
5 ttyS5 COM6
6 ttyS6 COM7
7 ttyS7 COM8
8 ttyS8 COM9
9 ttyS9 COM10
10 ttyS10 COM11
11 ttyS11 COM12
12 ttyS12 COM13
13 ttyS13 COM14
14 ttyS14 COM15
15 ttyS15 COM16
16 ttyUSB0 n.a.
17 ttyUSB1 n.a.
18 ttyUSB2 n.a.
19 ttyUSB3 n.a.
20 ttyUSB4 n.a.
21 ttyUSB5 n.a.
22 ttyAMA0 n.a.
23 ttyAMA1 n.a.
24 ttyACM0 n.a.
25 ttyACM1 n.a.
26 rfcomm0 n.a.
27 rfcomm1 n.a.
28 ircomm0 n.a.
29 ircomm1 n.a.
FreeBSD
30 cuau0 n.a.
31 cuau1 n.a.
Linux windows
0 ttyS0 COM1
1 ttyS1 COM2
2 ttyS2 COM3
3 ttyS3 COM4
4 ttyS4 COM5
5 ttyS5 COM6
6 ttyS6 COM7
7 ttyS7 COM8
8 ttyS8 COM9
9 ttyS9 COM10
10 ttyS10 COM11
11 ttyS11 COM12
12 ttyS12 COM13
13 ttyS13 COM14
14 ttyS14 COM15
15 ttyS15 COM16
16 ttyUSB0 COM17
17 ttyUSB1 COM18
18 ttyUSB2 COM19
19 ttyUSB3 COM20
20 ttyUSB4 COM21
21 ttyUSB5 COM22
22 ttyAMA0 COM23
23 ttyAMA1 COM24
24 ttyACM0 COM25
25 ttyACM1 COM26
26 rfcomm0 COM27
27 rfcomm1 COM28
28 ircomm0 COM29
29 ircomm1 COM30
30 cuau0 COM31
31 cuau1 COM32
32 cuau2 n.a.
33 cuau3 n.a.
34 cuaU0 n.a.
......@@ -169,35 +172,35 @@ List of comport numbers, possible baudrates and modes:
36 cuaU2 n.a.
37 cuaU3 n.a.
Linux windows
50 n.a.
75 n.a.
110 110
134 n.a.
150 n.a.
200 n.a.
300 300
600 600
1200 1200
1800 n.a.
2400 2400
4800 4800
9600 9600
19200 19200
38400 38400
57600 57600
115200 115200
230400 128000
460800 256000
500000 500000
576000 n.a.
921600 n.a.
Linux windows
50 n.a.
75 n.a.
110 110
134 n.a.
150 n.a.
200 n.a.
300 300
600 600
1200 1200
1800 n.a.
2400 2400
4800 4800
9600 9600
19200 19200
38400 38400
57600 57600
115200 115200
230400 128000
460800 256000
500000 500000
576000 n.a.
921600 921600
1000000 1000000
1152000 n.a.
1500000 n.a.
2000000 n.a.
1500000 1500000
2000000 2000000
2500000 n.a.
3000000 n.a.
3000000 3000000
3500000 n.a.
4000000 n.a.
......
......@@ -3,9 +3,9 @@
*
* Author: Teunis van Beelen
*
* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Teunis van Beelen
* Copyright (C) 2005 - 2019 Teunis van Beelen
*
* Email: [email protected]gmail.com
* Email: [email protected]protonmail.com
*
***************************************************************************
*
......@@ -26,8 +26,10 @@
*/
/* Last revision: November 22, 2017 */
/* Last revision: May 20, 2019 */
/* Added function to check for status of "RING" */
/* Added 921600, 1500000, 2000000, 3000000 baud rates for windows */
/* extended comport range to COM32 for windows */
/* For more info and how to use this library, visit: http://www.teuniz.net/RS-232/ */
......@@ -368,6 +370,17 @@ int RS232_IsDCDEnabled(int comport_number)
}
int RS232_IsRINGEnabled(int comport_number)
{
int status;
ioctl(Cport[comport_number], TIOCMGET, &status);
if(status&TIOCM_RNG) return(1);
else return(0);
}
int RS232_IsCTSEnabled(int comport_number)
{
int status;
......@@ -482,7 +495,7 @@ void RS232_flushRXTX(int comport_number)
#else /* windows */
#define RS232_PORTNR 16
#define RS232_PORTNR 32
HANDLE Cport[RS232_PORTNR];
......@@ -490,7 +503,11 @@ HANDLE Cport[RS232_PORTNR];
char *comports[RS232_PORTNR]={"\\\\.\\COM1", "\\\\.\\COM2", "\\\\.\\COM3", "\\\\.\\COM4",
"\\\\.\\COM5", "\\\\.\\COM6", "\\\\.\\COM7", "\\\\.\\COM8",
"\\\\.\\COM9", "\\\\.\\COM10", "\\\\.\\COM11", "\\\\.\\COM12",
"\\\\.\\COM13", "\\\\.\\COM14", "\\\\.\\COM15", "\\\\.\\COM16"};
"\\\\.\\COM13", "\\\\.\\COM14", "\\\\.\\COM15", "\\\\.\\COM16",
"\\\\.\\COM17", "\\\\.\\COM18", "\\\\.\\COM19", "\\\\.\\COM20",
"\\\\.\\COM21", "\\\\.\\COM22", "\\\\.\\COM23", "\\\\.\\COM24",
"\\\\.\\COM25", "\\\\.\\COM26", "\\\\.\\COM27", "\\\\.\\COM28",
"\\\\.\\COM29", "\\\\.\\COM30", "\\\\.\\COM31", "\\\\.\\COM32"};
char mode_str[128];
......@@ -533,8 +550,16 @@ int RS232_OpenComport(int comport_number, int baudrate, const char *mode)
break;
case 500000 : strcpy(mode_str, "baud=500000");
break;
case 921600 : strcpy(mode_str, "baud=921600");
break;
case 1000000 : strcpy(mode_str, "baud=1000000");
break;
case 1500000 : strcpy(mode_str, "baud=1500000");
break;
case 2000000 : strcpy(mode_str, "baud=2000000");
break;
case 3000000 : strcpy(mode_str, "baud=3000000");
break;
default : printf("invalid baudrate\n");
return(1);
break;
......@@ -705,6 +730,17 @@ int RS232_IsDCDEnabled(int comport_number)
}
int RS232_IsRINGEnabled(int comport_number)
{
int status;
GetCommModemStatus(Cport[comport_number], (LPDWORD)((void *)&status));
if(status&MS_RING_ON) return(1);
else return(0);
}
int RS232_IsCTSEnabled(int comport_number)
{
int status;
......
......@@ -3,9 +3,9 @@
*
* Author: Teunis van Beelen
*
* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Teunis van Beelen
* Copyright (C) 2005 - 2019 Teunis van Beelen
*
* Email: [email protected]gmail.com
* Email: [email protected]protonmail.com
*
***************************************************************************
*
......@@ -25,7 +25,7 @@
***************************************************************************
*/
/* Last revision: August 5, 2017 */
/* Last revision: May 20, 2019 */
/* For more info and how to use this library, visit: http://www.teuniz.net/RS-232/ */
......@@ -67,6 +67,7 @@ int RS232_SendBuf(int, unsigned char *, int);
void RS232_CloseComport(int);
void RS232_cputs(int, const char *);
int RS232_IsDCDEnabled(int);
int RS232_IsRINGEnabled(int);
int RS232_IsCTSEnabled(int);
int RS232_IsDSREnabled(int);
void RS232_enableDTR(int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment