 |
|
|
Topic: port.Output
|
By: Guest | Posted on: May 28 2010 at 11:36:54 AM | I tested the OCX and it doesn't appear to output the proper binary data in my application which currently uses MSComm32.
For instance:
port.Output = ChrB(&HFE) & ChrB(&HFE) & ChrB(&H7A) & ChrB(&HE0) & ChrB(&H6) & ChrB(&H1) & ChrB(&H1) & ChrB(&HFD)
outputs:
0x3f 0x3f 0x43 ox3f
| |
By: Support | Posted on: May 29 2010 at 04:09:46 PM | Hello - Would you email us - if we exchange a couple of emails we can maybe reproduce the problem and have a fix release ASAP.
support at comm32.com | |
By: Support | Posted on: May 30 2010 at 09:52:26 AM | I believe that the behavior you've described is normal. (MSComm does that too).
I'm sure you're aware that Windows stores characters in more than one byte. It does that so that it can handle all those international character sets where the standard ascii 0 to 255 is not enough.
VB String handling functions take this in to consideration and the MSComm.Output function is just a standard string handling function. In your example at the top of this page your raw bytes are being interpreted as a string which is then being converted by Windows so your 8 bytes end up as 4 ascii values.
When Microsoft created MSComm they added a property called InputModeBinary. They had to do that because, as a developer, you often have no control over the type of data you're receiving. You do have control over the data you're sending so Microsoft decided they didn't need a function called OutputModeBinary.
They didn't need such a property because a VB String can actually contain any data - each element in the string can contain any value 0 to 255 so instead of using ChrB( ) to send raw Bytes simply send your bytes using the Chr( ) function or join all your bytes together in a vb string something like this:
dim s as string
s= Chr(&HFE) & Chr(&HFE) & Chr(&H7A) & Chr(&HE0) & Chr(&H6) & Chr(&H1) & Chr(&H1) & Chr(&HFD)
Port.Output = s
After all that though - I do agree that we can improve on MScomm. We will look at the possibility of adding a new property, OutputModeBinary = True/False or other functions (OutByte, InByte, OutByteArray etc etc) which would then be able to transmit byte data as you expect. | |
|