Comm32 Logo
Home Button  Buy Button 

Topic:   Scomm32.Input is not producing a complete String in VBA - Bug?

By: Shawn O.Posted on: Jan 24 2019 at 03:30:41 PM
Good afternoon,

I am having an issue with a coding project in Access 2016. Up to this point I have never had this issue before and I do not know how to fix it. I will get a ASCII transmission from a COM port. I create a string variable to put the input data into. strSerialInput = SComm1.Input. In run time, when I look at the value of the variable I get the input string, but it does not close the string with a quote. Say I send "Hello". I would expect the value to say (strSerialInput = "Hello"), but what I am seeing is (strSerialInput = "Hello)

By: Shawn O.Posted on: Jan 24 2019 at 03:32:30 PM
It cut off my message - here is the rest:

By: Shawn O.Posted on: Jan 24 2019 at 03:33:17 PM
Oops- had a bad tag: I am missing the last quote. I have tried rebooting, even starting a new database and the issue follows. Any ideas why? I use this software all the time and I have never seen this behavior before. Please Help!

By: Shawn O.Posted on: Jan 25 2019 at 06:05:00 AM
Well - I figured it out. I am using a Serial TCP-IP Gateway from RTA to communicate with Access. Apparently the RTA module can concatenate prefix and suffix to the string it issues. So when the module contcats Carriage Return and Line Feed (or either one) the SComm buffer must not know what to do with them and overruns. I also confirmed that behavior using RealTerm and a virtual serial port connection. That leaves the String Variable in an inconsistent state. So note to everyone - beware what you send to the SComm com port.

By: GuestPosted on: Jan 29 2019 at 10:22:41 AM
SComm doesn't behave differently when it gets carriage return or line feed. In fact it doesn't care. They're just bytes and it stores those bytes and you read them from the receive buffer.

If you are responding to OnComm events bear in mond that if you're expecting a number of characters that the OnComm event is triggered before the whole packet arrives and if you immediately read the receive buffer you'll only get whatever characters are in the receive buffer. Remaining characters can still be in transit. So, in theory, you'd need to respond to your oncomm even and hang around waiting for all the characters. But that's not good code. So, setup an global string and when you get an oncomm even just append the rx data into that global string. Keep responding to oncomm events till the whole packet is in the string.

But if your devices are prefixing or suffixing characters then scomm doesn't know or care. it's up to you to remove any prefixes or suffixes that you don't want.

Reply - add a comment to this topic.

You may enter letters, numbers and standard punctuation only. HTML and other scripts/tags will be rejected.

Topic:- Scomm32.Input is not producing a complete String in VBA - Bug?


Enter the numbers.

Your name here is optional