> I'm trying to manipulate the DTR signal of the serial port. > As an example I used this code snippet: > http://lists.exploits.org/upsdev/Feb2004/00013.html. > I can open the com1, I can send and receive data but the ioctl I use > to read the status of the signals returns -1: > > int status; > ioctl(upsfd, TIOCMGET, &status); > > Anybody can help me? I have no idea about what's wrong with this code.
strace would give a hint. TIOCMGET should only fail because a call to GetCommModemStatus fails. If so, the strace would contain a line which talks about setting errno in fhandler_serial::ioctl.
Corinna,
thanks a lot for your advice. I tried to use strace. Here is what I see:
...
Attached to pid 3260 (windows pid 3252)
4 4 [main] test 3260 nanosleep: 0 = nanosleep (2000, 0)
149 153 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
34 187 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
28 215 [main] test 3260 writev: writev (1, 0x22D840, 1)
25 240 [main] test 3260 fhandler_console::write: A0503C0, 17
21 261 [main] test 3260 fhandler_console::write: at 67(C) state is 0
645 906 [main] test 3260 fhandler_console::write: 17 = write_console (,..17)
67 973 [main] test 3260 writev: 17 = write (1, 0x22D840, 1), errno 22
26 999 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
21 1020 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
25 1045 [main] test 3260 ioctl: fd 3, cmd 5415
23 1068 [main] test 3260 fhandler_base::ioctl: -1 = ioctl (5415, 0x22EE24)
21 1089 [main] test 3260 ioctl: returning -1
22 1111 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
27 1138 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
23 1161 [main] test 3260 writev: writev (1, 0x22D840, 1)
22 1183 [main] test 3260 fhandler_console::write: A0503C0, 20
20 1203 [main] test 3260 fhandler_console::write: at 115(s) state is 0
92 1295 [main] test 3260 fhandler_console::write: 20 = write_console (,..20)
26 1321 [main] test 3260 writev: 20 = write (1, 0x22D840, 1), errno 22
21 1342 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
20 1362 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
21 1383 [main] test 3260 ioctl: fd 3, cmd 5418
20 1403 [main] test 3260 fhandler_base::ioctl: -1 = ioctl (5418, 0x22EE24)
20 1423 [main] test 3260 ioctl: returning -1
25 1448 [main] test 3260 nanosleep: nanosleep (2000)
1999523 2000971 [main] test 3260 nanosleep: 0 = nanosleep (2000, 0)
122 2001093 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
3405 2004498 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
71 2004569 [main] test 3260 writev: writev (1, 0x22D840, 1)
25 2004594 [main] test 3260 fhandler_console::write: A0503C0, 17
21 2004615 [main] test 3260 fhandler_console::write: at 67(C) state is 0
145 2004760 [main] test 3260 fhandler_console::write: 17 = write_console (,..17)
100 2004860 [main] test 3260 writev: 17 = write (1, 0x22D840, 1), errno 22
160 2005020 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
28 2005048 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
25 2005073 [main] test 3260 ioctl: fd 3, cmd 5415
23 2005096 [main] test 3260 fhandler_base::ioctl: -1 = ioctl (5415, 0x22EE24)
20 2005116 [main] test 3260 ioctl: returning -1
20 2005136 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
24093 2029229 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
67 2029296 [main] test 3260 writev: writev (1, 0x22D840, 1)
25 2029321 [main] test 3260 fhandler_console::write: A0503C0, 20
20 2029341 [main] test 3260 fhandler_console::write: at 115(s) state is 0
22715 2052056 [main] test 3260 fhandler_console::write: 20 = write_console (,..20)
88 2052144 [main] test 3260 writev: 20 = write (1, 0x22D840, 1), errno 22
16903 2069047 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
90 2069137 [main] test 3260 __cygwin_lock_unlock: threadcount 1. not unlocking
30 2069167 [main] test 3260 ioctl: fd 3, cmd 5418
26 2069193 [main] test 3260 fhandler_base::ioctl: -1 = ioctl (5418, 0x22EE24)
22 2069215 [main] test 3260 ioctl: returning -1
30 2069245 [main] test 3260 nanosleep: nanosleep (2000)
1999103 4068348 [main] test 3260 nanosleep: 0 = nanosleep (2000, 0)
122 4068470 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
33 4068503 [main] test 3260 __cygwin_lock_lock: threadcount 1. not locking
29 4068532 [main] test 3260 writev: writev (1, 0x22D840, 1)
I can't see any ioctl call to GetCommModemStatus :( Am I missing something?
llandre
DAVE Electronics System House - R&D Department web: http://www.dave-tech.it email: r&[EMAIL PROTECTED]
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/