summaryrefslogtreecommitdiff
path: root/RS-232/demo_rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'RS-232/demo_rx.c')
-rw-r--r--RS-232/demo_rx.c72
1 files changed, 0 insertions, 72 deletions
diff --git a/RS-232/demo_rx.c b/RS-232/demo_rx.c
deleted file mode 100644
index 94bd8c3..0000000
--- a/RS-232/demo_rx.c
+++ /dev/null
@@ -1,72 +0,0 @@
-
-/**************************************************
-
-file: demo_rx.c
-purpose: simple demo that receives characters from
-the serial port and print them on the screen,
-exit the program by pressing Ctrl-C
-
-compile with the command: gcc demo_rx.c rs232.c -Wall -Wextra -o2 -o test_rx
-
-**************************************************/
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef _WIN32
-#include <Windows.h>
-#else
-#include <unistd.h>
-#endif
-
-#include "rs232.h"
-
-
-
-int main()
-{
- int i, n,
- cport_nr=0, /* /dev/ttyS0 (COM1 on windows) */
- bdrate=9600; /* 9600 baud */
-
- unsigned char buf[4096];
-
- char mode[]={'8','N','1',0};
-
-
- if(RS232_OpenComport(cport_nr, bdrate, mode))
- {
- printf("Can not open comport\n");
-
- return(0);
- }
-
- while(1)
- {
- n = RS232_PollComport(cport_nr, buf, 4095);
-
- if(n > 0)
- {
- buf[n] = 0; /* always put a "null" at the end of a string! */
-
- for(i=0; i < n; i++)
- {
- if(buf[i] < 32) /* replace unreadable control-codes by dots */
- {
- buf[i] = '.';
- }
- }
-
- printf("received %i bytes: %s\n", n, (char *)buf);
- }
-
-#ifdef _WIN32
- Sleep(100);
-#else
- usleep(100000); /* sleep for 100 milliSeconds */
-#endif
- }
-
- return(0);
-}
-