Applies To: |
|
Summary: |
I have used the Cicode example given in the
help for ComOpen. I have modified this cicode slightly, so that it
can read and write data to an ASCII Printer. When I hard code a String to the buffer, it works fine: sBuffer = "TEST";
sBuffer = TagRead("VarTag");
|
Solution: |
The problem lies ultimately with timing,
and also the position of the ComClose function. When you hardcode
the sBuffer value in cicode, it is sent out the wire, before the
ComClose function is called. But when you use Cicode assignment, it
takes a little longer. When the ComClose function is called, the
ComWrite function has not completed, and suffers interference. To
resolve this problem, it is recommended to insert a SleepMS before
the ComClose function is called. It would actually be better practice to only open the Com port on startup, and close the com port on Shutdown. Some example Cicode has been uploaded to the toolbox. It is recommended if you are experiencing problems writing your Com function, you take a look at this Cicode example. |
Keywords: |
cicode error 257, ComClose, ComWrite |
Related Links
Attachments