02-21-2006 12:46 PM
02-22-2006 11:58 AM
02-22-2006 01:24 PM
Yes, I've looked at this ( and before ), but this doesn't tell me everthing. I get data, but in multiples of groups instead of a group at a time. So far, it works no differently or better than MSCOMM.
Have anything else?
02-23-2006 10:19 AM - edited 02-23-2006 10:19 AM
Message Edited by Patrick P. on 02-23-2006 10:20 AM
02-23-2006 12:33 PM
What I mean is if I'm receiving 3 bytes ( a group ), I get 6 or 9 bytes together rather than 3 bytes. Even if I set the threshold to 3, I get more than 3. Why? The data is sent at regular, predictable intervals.
No termination character.
This still doesn't answer basic questions, such as how to open a port, close a port, determine if the port is open or closed. I get that "Configure" probably opens it, but what closes it? What, in detail, does "Reset" do? How do I ping a port to see if it exists? These details are what are characteristically missing from NI documentation.
>...check out the Measurement Studio reference help ...
Ok, where is it? I don't have a manual.
>It lists all of these.
Ok, but I'll bet it lists them and doesn't explain them.
02-23-2006 05:24 PM
The help should be installed by default if you installed Measurement Studio. The easiest way to get to it is to go through your start menu. The help is located at Start>>Programs>>National Instruments>>Measurement Studio>>Help>>Measurement Studio Reference. Then from there I just did a search on CWserial. It lists and explains several of the things I believe you are looking for. If you still can’t find it, I can post the help files here for you.
I was curious how you were setting the threshold to read? Were calling a Read or ReadAsync with a value of three?02-23-2006 07:24 PM
Yes, this is better. However, it still doesn't explain how to use them together. For example, if I select cwserial1.read, how is this invoked? In what circumstances would I use it over ReadAsync?
Honestly, I've tried the example programs. They are a bit flaky and sometimes flat don't work. In this case, the example is not really different than the typical MSCOMM type of approach. What am I missing?
>I was curious how you were setting the threshold to read?
I was using a slider to modify the value from 1 to 10 for test purposes.
>Were calling a Read or ReadAsync with a value of three?
Read on a timer. From examples I've seen using MSCOMM, you hammer it with calls until you get something. Then process it. Or, wait for OnComm event to fire then collect it. But, I always have to collect it in pieces, not the entire string. This is the core of the problem I'm having.
02-24-2006 05:02 PM
I have this connected to a button and the DataReady procedure. It does nothing until I click the button.
CWSerial1.ReadAsync 3 ' I want 3 bytes at a time...
Private Sub CWSerial1_DataReady(ByVal taskNumber As Integer, data As Variant)
lstData.AddItem data, 0
End Sub
02-27-2006 10:01 AM
When you use ReadAsync, it is setting up just a single
read. If you want it to continuously
keep reading 3 bytes, you would just add a ReadAsync 3 inside of your dataready
event handler. This way it would always set another 3 bytes to read.
I don’t know of a single function call you can make to view all of the available serial ports. If you want to get all of them with the CWSerial control, you could create a global Boolean that tells you whether an error occurred or not within configuration. It would be similar to the code you had listed above for the mscomm interface. You would need to create a global variable called ConfigError.
CWSerial1.ExceptionOnError = False
ConfigError =
False
For I = 1 To 20
' Try each in turn
CWSerial1.ComPort
= I
CWSerial1.Configure
If ConfigError =
False Then
MsgBox
"add port to list"
End If
ConfigError =
False
Next I
02-27-2006 12:22 PM
BINGO!! It is the same approach, but at least I have an answer and some useful details.
For the benefit of others, here is some more info I received from another source:
To find out which ports are enumerated use the SetupDiGetDeviceRegistryProperty from the setupapi.h library. The ‘SPDRP_FRIENDLYNAME’ field contains the device descriptor and allocated COM port.
Useful links:
SetupDiGetDeviceRegistryProperty:
Example code: