|
-
Nov 22nd, 2009, 12:45 PM
#15
Re: VB6.0: MSComm gives me ascii character but i need single data type !!
Geezz, I thought I was confused before! This makes absolutely no sense at all. How can you possibly be sending an Ascii string ( MSComm1.Output = "-0.02934" ) from Matlab?? Your InputMode = Text, so it should read the characters sent from Matlab as same.
(1) Are you sure that you're not sending Binary data from Matlab?
(2) Are you certain that your Comm Settings in Matlab & MSComm are identical?
Either one of these issues can result in gibberish being received. If the Settings don't agree the data received will be out of sync with the transmitter (Matlab). This will result in the received data being totally random.
Let's talk about InputLen.... The experiments that I've made with this property tells me two things.
(1) The Library description is misleading. This is what it says:
Sets and returns the number of characters the Input property reads from the receive buffer.
This statement might lead one to believe that if InputLen = 8 then it would only read the buffer if there were 8 chars in the InBuffer. The truth is the InputLen property sets the Maximum number of characters that will be read. If the InBuffer contains less than InputLen it will still read them, even if it's 1 char. If the InBuffer contained 12 chars then only the first 8 received chars would be read. Mscomm provides the InBufferCount property that can be used in an If statement to manipulate and action. With it you can specify =, <, >, >=, <= or <> then do something.
(2) I do not find the InputLen property useful in the On_Comm Event where RThreshold rules. Personally, I find it far more useful when used in Polling the InBuffer. Evidently MSDN must have agreed because the example they give is in a Command_Click event, not On_Comm. Polling is more often utilized in a TimerControl though.
FYI: I taught myself, (and I'm still teaching myself) MSComm with the use of Loopback testers and Nullmodems. There is absolutely no better way to learn the quirks of MSComm. If you plan on doing much work with the Serial Port I would highly recommend arming yourself with them. Both can be purchased on line cheap, complete with LED indicators for all your RS232 nodes.
Last edited by CDRIVE; Nov 22nd, 2009 at 06:24 PM.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|