LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Device with both RS232 and TCPIP

Gurus,

 

I'm writing a driver for a new instrument I designed.  It has an RS232 port and an internal RS232<>Wifi module from Roving Networks.  I wrote the RS232 vi's using VISA.  Now I'm trying to figure the best way to handle both types of comms within one vi.  So far I added my TCP address into MAX, it shows up in the list of VISA's.  

 

I put in a boolean switch on the panel (select TCPIP or RS232) and a CASE in the code to switch between initializing RS232/TCPIP.  Looks sloppy though...  It keeps crashing on a VISA READ ("lost comms"?) even though the init works fines with no errors, but I'll try to debug that..

 

I'm a HW guy creating drivers, don't know all the "fun" stuff you guys do Smiley Happy

 

1 - What is the best practive way to implement a dual-comms driver?

2 - Does any PC I install this driver on have to have MAX on it (to configure the TCPIP socket?

3 - Can anyone share an init / write & get data vi's please who has done this?  My device only has 4 values to read/write, so very simple.

 

Thanks!!!!

Streve

0 Kudos
Message 1 of 3
(2,300 Views)

You can format the VISA resource name directly allowing you to communicate using VISA using either the RS-232 or TCP connection. The piece of your code that will need to care about this is the initialization. Everything down stream will simply use VISA read or write. If you don't know the exact size of the returned data or you don't have a delimiter for your messages a method to read unknown sizes of data is to read a single byte. This read will use a longer timeout. Once a single character is read read chunks of data (some reasonable size) but use a much shorter timeout. The logic here is that there will be a break between messages. The shorter timeout should be less than the expected interval between messages.

 

Since you will be using both serial and TCP communications don't use the Bytes At Port method in VISA. This only applies to the serial connection and therefore your general read/write VIs will have to have logic to differentient behavior based on the connection type. You should avoid doing this and limit that to the initialization only.

 

I have implemented several variotions of a generic communication interface library. The most recent is LVOOP. I am not at liberty to post these however. But it is very doable.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 3
(2,295 Views)

Thanks for the feedback. Indeed the bytes at port is biting me atm, can't figure out how to access the buffer to get a size.  I can set the TCPIP0::... in VISA name, open it OK though.

0 Kudos
Message 3 of 3
(2,272 Views)