Serial Communication

393 views
Skip to first unread message

HH

unread,
Jan 12, 2017, 9:52:14 AM1/12/17
to multisoft FlagShip
Adjusted lately a data recording software I compiled with FlagShip to approach different COM PORTS, where RFID readers and a scale present
the data. Reading out the data works fine but only after I have been running first a tool to open, initialize and close the different COM PORTS,
despite I do this also and again in my programs
. For the "preparation" of the ports I use a package called  "HTerm".

What I missed in my source code to approach the ports without the help of HTerm ?

******************************************************************************
* Reading RFID's
******************************************************************************
@ 20,20 say "Transponder:"
store 99 to x
do while x=99
COM_OPEN(6)
COM_INIT(6, 9600, "N", 8, 1)
cInput3 := COM_READ(6, 16)              // Reads in 16 characters
store cInput3 to zid
@ 20,36 say zid pict "!!!!!!!!!!!!!!!!"
COM_CLOSE(6)


Adam Lord

unread,
Jan 16, 2017, 7:10:16 AM1/16/17
to multisoft FlagShip
I am using following function which works fine (without HTerm):

*************************************
xData := myComRead(4)
if len(xData) > 0
   ? "data read: [" + xData + "] len=" + ltrim(len(xData))
endif

FUNCTION myComRead(comport)
local cData=""
local ok := .F.
IF com_open(comport)
   com_hard(comport,.F.)   
   com_soft(comport,,.F.)
   com_timeout(comport, 10, 0, 100, 0, 100)  // Windows
   IF com_init(comport,9600,"N",8,1)
      ok := .T.
   ENDIF
ENDIF
if ok
   cData := com_read(comport)
else
   alert("cannot open COM port#" + ltrim(comport))
endif
com_close(comport)
return cData

*************************************

Hope this helps you,
AL

HH

unread,
Jan 18, 2017, 6:23:15 AM1/18/17
to multisoft FlagShip
Thanks Adam for this hint. Tried to implement the handshake and timeout commands but this doesn't help.
There must be somethimg else I have to when approaching the hardware of at least two of my linked devices.
One RFID reader works properly without running HTerm but another one and a scale which I linked need to be
opened and initialized  first with HTerm. May be our tools do not properly initialize the DCB ?

Reagrds !

HH

Adam Lord

unread,
Jan 20, 2017, 5:10:50 AM1/20/17
to multisoft...@googlegroups.com
Hi, I have no idea which handshake your RFID reader use. If not RTS/CTS but DTR/DSR, use COM_HARD(nPort, .T., .T.) and/or COM_DTR(nPort, .T.) to enable it.

I agree, the documentation of the COM interface is very thin (as opposed to the usual flagship documentation, which I very like). However, because the source is present and well commented in fs2_com.prg, this can be good used as a guide.

AL
Reply all
Reply to author
Forward
0 new messages