flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 13 Mar 2010, 00:09
I think your code is OK, but check this one in case something was missing: http://board.flatassembler.net/topic.php?t=6459
What device do you have at the other end? Are you sure it is working in the same mode and that it is actually sending something? Maybe your timeouts are set to wait forever and that is the reason for the block? |
|||
![]() |
|
mindcooler 13 Mar 2010, 16:02
Well, it was supposed to block until something got through. With a timeout it just went through with a read count of 0.
It turns out my DCB was wrong. Code: DWORD fBinary :1; DWORD fParity :1; DWORD fOutxCtsFlow :1; DWORD fOutxDsrFlow :1; DWORD fDtrControl :2; DWORD fDsrSensitivity :1; DWORD fTXContinueOnXoff :1; DWORD fOutX :1; DWORD fInX :1; DWORD fErrorChar :1; DWORD fNull :1; DWORD fRtsControl :2; DWORD fAbortOnError :1; DWORD fDummy2 :17; Apparently this is only ONE DWORD, and not 13 :S A fixed DCB and a Code: mov [dcb.flags],$80000000 and it works. _________________ This is a block of text that can be added to posts you make. |
|||
![]() |
|
mindcooler 13 Mar 2010, 21:02
Here's the entire test program if anyone is interested. It reads a byte at a time and puts it in the window title:
Code: struct DCB DCBlength dd ? BaudRate dd ? flags dd ? wReserved dw ? XonLim dw ? XoffLim dw ? ByteSize db ? Parity db ? StopBits db ? Xondb db ? Xoffdb db ? Errordb db ? Eofdb db ? Evtdb db ? wReserved1 dw ? ends struct COMMTIMEOUTS ReadIntervalTimeout dd ? ReadTotalTimeoutMultiplier dd ? ReadTotalTimeoutConstant dd ? WriteTotalTimeoutMultiplier dd ? WriteTotalTimeoutConstant dd ? ends Code: include 'win32wxp.inc' include 'dcb.inc' .code start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc invoke CreateWindowEx,0,_class,_class,WS_VISIBLE+WS_OVERLAPPEDWINDOW+CS_HREDRAW+CS_VREDRAW,$100,$100,800,600,NULL,NULL,[wc.hInstance],NULL mov [hwin],eax invoke CreateFile,_com,GENERIC_READ or GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0 mov [hcom],eax invoke GetCommState,eax,dcb mov [dcb.BaudRate],38400 mov [dcb.ByteSize],8 mov [dcb.Parity],0 mov [dcb.StopBits],0 mov [dcb.flags],$80000000 invoke SetCommState,[hcom],dcb mov [timeout.ReadTotalTimeoutConstant],1000 invoke SetCommTimeouts,[hcom],timeout invoke CreateThread,NULL,0,treceive,NULL,0,n .msgloop: invoke GetMessage,msg,NULL,0,0 or eax,eax jz .exit cmp eax,-1 je .exit invoke TranslateMessage,msg invoke DispatchMessage,msg jmp .msgloop .exit: ret treceive: invoke ReadFile,[hcom],buffer,1,n,NULL cmp [n],0 je @f invoke SetWindowText,[hwin],buffer @@: cmp [term],0 je treceive WindowProc: virtual at esp+8 .wmsg rd 1 end virtual cmp [.wmsg],WM_DESTROY jne .default invoke PostQuitMessage,0 not [term] .exit: xor eax,eax ret $10 .default: jmp [DefWindowProc] .end start .data _class TCHAR 'classy',0 _com TCHAR 'COM1',0 wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,WHITE_PEN,NULL,_class buffer db 0 db 0 dw 0 msg MSG dcb DCB timeout COMMTIMEOUTS n rd 1 hcom rd 1 hwin rd 1 term rd 1 _________________ This is a block of text that can be added to posts you make. |
|||
![]() |
|
Zetus 29 Mar 2010, 11:53
same problem/tnx a lot
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.