MIDAS
Loading...
Searching...
No Matches
rs232test.cxx
Go to the documentation of this file.
1/********************************************************************\
2
3 Name: rs232test.c
4 Created by: Stefan Ritt
5
6 Contents: Simple RS232 test program, needs
7 midas/drivers/bus/rs232.c
8
9 $Id:$
10
11\********************************************************************/
12
13#include <midas.h>
14#include "rs232.c"
15
16int main()
17{
19 char str[10000];
20
21 printf("Enter port [/dev/ttyS0]: ");
22 fgets(str, sizeof(str), stdin);
23 if (strchr(str, '\n'))
24 *strchr(str, '\n') = 0;
25
26 if (!str[0])
27 strcpy(str, "/dev/ttyS0");
28
29 info.fd = rs232_open(str, 9600, 'N', 8, 1, 0);
30
31 if (info.fd < 0) {
32 printf("Cannot open ttyS0\n");
33 return 0;
34 }
35
36 /* turn on debugging, will go to rs232.log */
38
39 printf("Connected to ttyS0, exit with <ESC>\n");
40
41 do {
42 memset(str, 0, sizeof(str));
43 str[0] = ss_getchar(0);
44 if (str[0] == 27)
45 break;
46
47 if (str[0] > 0)
49
50 rs232_gets(&info, str, sizeof(str), "", 10);
51 printf(str);
53
54 } while (1);
55
58
59 return 1;
60}
#define CMD_DEBUG
Definition midas.h:815
INT ss_getchar(BOOL reset)
Definition system.cxx:7503
void ** info
Definition fesimdaq.cxx:41
#define TRUE
Definition midas.h:182
char str[256]
Definition odbhist.cxx:33
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
int main()
Definition rs232test.cxx:16