user945761
user945761

Reputation: 21

Can Open serial port RS232 but cannot setup or send ascii

I'm trying to send an ascii string through win10 serial port. I tried through Teraterm software with not problem. This device receive ascii character and turn on LED. I was able to open the port and flush it ATEasy 2023,and get an handle with ComGetHandle. But I when I try to set the port with ConSetup command or send ascii string with ComSend I get an error. I also tried with debug with but got the same errors. The code is here.

! Com Open
If ComOpen(5) < 0
  Abort
Endif

AHandle = ComGetHandle(5)


! Set Port
lStatus = ComSetup(5, 9600, 8, aComParityNone, aComStopBits1_5, aComHandshakeNone)
if lStatus < 0
   ComClose(5)
   Abort
endif

! Clear Port Reset ( ) 
lStatus = ComFlush(5, aioFlushBoth)
if lStatus < 0
   ComClose(5)
   Abort
endif

!Port Send
lBytes = ComSend(5, "\r", 1000, aioDefault, "O1", 4)
if lBytes < 0
   ComClose(5)
   Abort
endif

!Close Port
! Com Open
If ComClose(5) < 0
   Abort
Endif

What can be the reason?

Try to send ascci string and expect the device to turn on the lED.

Upvotes: 0

Views: 32

Answers (0)

Related Questions