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
16
int
main
()
17
{
18
RS232_INFO
info
;
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 */
37
rs232
(
CMD_DEBUG
,
TRUE
);
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)
48
rs232_puts
(&
info
,
str
);
49
50
rs232_gets
(&
info
,
str
,
sizeof
(
str
),
""
, 10);
51
printf
(
str
);
52
fflush
(
stdout
);
53
54
}
while
(1);
55
56
ss_getchar
(
TRUE
);
57
rs232_exit
(&
info
);
58
59
return
1;
60
}
CMD_DEBUG
#define CMD_DEBUG
Definition
midas.h:815
ss_getchar
INT ss_getchar(BOOL reset)
Definition
system.cxx:7503
info
void ** info
Definition
fesimdaq.cxx:41
midas.h
TRUE
#define TRUE
Definition
midas.h:182
str
char str[256]
Definition
odbhist.cxx:33
h1_book
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition
rmidas.h:24
main
int main()
Definition
rs232test.cxx:16
progs
rs232test.cxx
Generated on Sat May 3 2025 05:01:06 for MIDAS by
1.9.8