1 #include "ace/DEV_Connector.h"
2 #include "ace/TTY_IO.h"
3 #include "ace/OS_NS_unistd.h"
5 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
8 ACE_ERROR_RETURN ((LM_ERROR
,
9 ACE_TEXT ("usage: %s device-filename\n"),
13 ACE_DEV_Connector con
;
15 if (con
.connect (write_dev
,
16 ACE_DEV_Addr (argv
[1])) == -1)
17 ACE_ERROR_RETURN ((LM_ERROR
,
22 ACE_TTY_IO::Serial_Params myparams
;
23 // Try to read default parameters
24 if (write_dev
.control (ACE_TTY_IO::GETPARAMS
, &myparams
) == -1)
26 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("GETPARAMS is not supported\n")));
30 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("GETPARAMS is supported\n")));
33 myparams
.baudrate
= 19200;
34 myparams
.readmincharacters
= 0;
35 myparams
.readtimeoutmsec
= 10*1000; // 10 seconds
37 if (write_dev
.control (ACE_TTY_IO::SETPARAMS
, &myparams
) == -1)
38 ACE_ERROR_RETURN ((LM_ERROR
,
40 ACE_TEXT ("control")),
44 ACE_TEXT ("enter character to send, q terminates :\n")));
47 ACE_OS::read (ACE_STDIN
, &writeto
, 1) != -1;
50 ssize_t bytes_written
=
51 write_dev
.send_n ((void *) &writeto
,
54 if (bytes_written
!= 1)
55 ACE_ERROR_RETURN ((LM_ERROR
,
63 if (write_dev
.close () == -1)
64 ACE_ERROR_RETURN ((LM_ERROR
,