1 #include "ace/DEV_Addr.h"
2 #include "ace/DEV_Connector.h"
3 #include "ace/TTY_IO.h"
5 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
8 ACE_ERROR_RETURN ((LM_ERROR
,
9 ACE_TEXT ("usage: %s device-filename\n"),
14 ACE_DEV_Connector con
;
16 if (con
.connect (read_dev
,
17 ACE_DEV_Addr (argv
[1])) == -1)
18 ACE_ERROR_RETURN ((LM_ERROR
,
23 ACE_TTY_IO::Serial_Params myparams
;
24 // Try to read default parameters
25 if (read_dev
.control (ACE_TTY_IO::GETPARAMS
, &myparams
) == -1)
27 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("GETPARAMS is not supported\n")));
31 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("GETPARAMS is supported\n")));
34 myparams
.baudrate
= 19200;
35 myparams
.readmincharacters
= 0;
36 myparams
.readtimeoutmsec
= 10*1000; // 10 seconds
38 if (read_dev
.control (ACE_TTY_IO::SETPARAMS
, &myparams
) == -1)
39 ACE_ERROR_RETURN ((LM_ERROR
,
40 ACE_TEXT ("%p control\n"),
44 // Read till character 'q'.
45 for (char readback
= 'x'; readback
!= 'q'; )
48 read_dev
.recv ((void *) &readback
, 1);
52 ACE_TEXT ("read: %c\n"),
54 else if (bytes_read
== 0)
56 ACE_TEXT ("timeout!\n")));
57 else if (bytes_read
== -1)
58 ACE_ERROR_RETURN ((LM_ERROR
,
59 ACE_TEXT ("%p recv\n"),