From: Vladimir T. <vtz...@gm...> - 2009-09-29 09:44:33
|
On 9/29/09, Angel Popov <ang...@ya...> wrote: > Thanks for the advise, > > Here is the debug session, but still cannot figure out what is going on. > Found an article that could be related > http://msdn.microsoft.com/en-us/library/ms687032(VS.85).aspx - It could be > something with ENABLE_LINE_INPUT console mode. > > the lisp program is > > (defvar com (open "COM1" :direction :io)) > (print (read-char-will-hang-p com)) > > The trace session: > > Breakpoint 1, fd_read_wont_hang_p (fd=0x73c) at ../src/win32aux.d:449 > 449 switch (GetFileType(fd)) { > 1: fd = (HANDLE) 0x73c > (gdb) s > 453 if (GetNumberOfConsoleInputEvents(fd,&nevents)) { /* It's a > console. */ > 1: fd = (HANDLE) 0x73c > (gdb) n > 489 } else if (!(GetLastError()==ERROR_INVALID_HANDLE)) { > 1: fd = (HANDLE) 0x73c > (gdb) n > 494 switch (WaitForSingleObject(fd,0)) { > 1: fd = (HANDLE) 0x73c > (gdb) s > 496 return 1; WaitForSingleObject cannot be used on serial port handles - http://msdn.microsoft.com/en-us/library/ms687032(VS.85).aspx. Notice that files and serial ports are not in the list - wondering why it does not return an error? For checking whether there are characters to be read - ClearCommError() may be used (http://msdn.microsoft.com/en-us/library/aa363180(VS.85).aspx). In order to use it we should have explicit knowledge that this is serial port handle or just try it an handle the error in case it's not (probably ERROR_INVALID_HANDLE). Sam? |