News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Serial Port

Started by emmandedel, March 28, 2016, 04:23:37 AM

Previous topic - Next topic

emmandedel

Hi may I ask how to open a Serial Port?
I want to make a small project that when I press a certain keyboard button, the RTS of serial port is on so my device will receive it.
In other word, when i Press a button in keyboard, RTS is on / else RTS is off.?
I have a hard time search how to open a serial port in MASM32.

jj2007

Some stuff to read over Easter:
http://www.masmforum.com/board/index.php?topic=16253.0
http://www.masmforum.com/board/index.php?topic=13693.0
http://www.masmforum.com/board/index.php?topic=5972.0
http://www.masmforum.com/board/index.php?topic=4408.msg32990#msg32990
http://www.masmforum.com/board/index.php?topic=3584.msg26872#msg26872
http://www.masmforum.com/board/index.php?topic=3536.msg26794#msg26794
http://www.masmforum.com/board/index.php?topic=428.msg3727#msg3727
http://masm32.com/board/index.php?topic=4000.msg42150#msg42150

Welcome to the forum :icon14:

Mikl__


Siekmanski

Hi emmandedel,

Welcome to the forum.

You could try this,


.data
Com4 db "\\.\COM4", 0
hComPort dd 0

.code
invoke CreateFile,addr Com4,GENERIC_READ or GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
mov hComPort,eax

invoke EscapeCommFunction,hComPort,SETRTS

invoke EscapeCommFunction,hComPort,CLRRTS

invoke CloseHandle,hComPort


https://msdn.microsoft.com/nl-nl/library/windows/desktop/aa363254(v=vs.85).aspx
Creative coders use backward thinking techniques as a strategy.

jj2007

Welcome, Dornmino :icon14:
Tell your coder that you could be improved a little bit. We are always willing to help :biggrin: