LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Instrument I/O Assistant

Solved!
Go to solution
I am trying to set up a serial Tx and Rx to a third party device via USB. I can assign the Instrument I/O Assistant to the correct COM port and can write and read. The Instrument I/O Assistant wants the Tx string but I want to manually enter the Tx string from the .uir when it is running. Thus what I want is to send Tx data via a Text box and use a loop back to receive the data back in another text box. With the Instrument I/O Assistant I can send and recieve the text in the Write and read steps but I want to enter different text each time. There must be code for this? Should I even be using the Instrument I/O Assistant?
0 Kudos
Message 1 of 13
(4,440 Views)
I cannot help you with the Instrumenti I/O Assistant since I never used it: I use extensively serial communication both for proprietary and third party devices and always used standard RS232 library commands. I suggest you search the serial example (<example folder>\rs232\serial.cws) that offers you basic read and write facilities using the rs232 library: this may offer you a framework to handle communication with your device.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 13
(4,433 Views)

Thanks Roberto.

That is what I am looking for. I searched the NI website but did not know it was installed on my PC. The comms work fine. Now what I need to do is select one of 32 COM ports and Monitor the RS232 traffic and/or manually test the the COM port with Tx and Rx text. Do you have any canned code?

0 Kudos
Message 3 of 13
(4,419 Views)

Well, I use no special code for this: simply shorting pins 2 and 3 of the com port together makes every message sent to be received on the same port, so you can initially test you app with some ComWrt and the corresponding ComRd.

...or am I misunderstanding your question?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 13
(4,417 Views)

The comms work fine with shorting the pins for testing.

What I need now is:

-  to display the RS232 traffic on a emulation of a DOS screen (80x24 characters)

- Select one of 32 channels of RS232 data, then I only need one text window

- Tx data red, Rx data black

- Manually enter Tx data and receive Rx data for testing

 

I assumea a lot of this will be done with Tx data buffers and Rx data buffers. 

Have you seen an 80x24 character DOS type screen by chance?

 

I have to update a legacy system and add some automation to it.

0 Kudos
Message 5 of 13
(4,410 Views)

You're right: input and output buffers will be used for serial I/O. Regarding mimicing a DOS screen, I'm not aware of a mode to obtain it if you intend to have the whole screen confined to that region (BTW I have seen lots of DOS screens! My career started in DOS world and sometimes I am still using it for fast testing of communications with external devices Smiley Happy ). You will need to develop your own terminal-like application, possibly using a textbox as operator input area and a listbox as the output (the only native control capable of displaying text in different colors, well... not considering here tables, which I consider oversized for such a task). On every commit event on the textbox (the user pressing Enter after entering some text) you will need to:

  • read the textbox in a buffer and clear it
  • pass the buffer to ComWrt
  • echo the command to the listbx with the correct color
  • wait for the appropriate time for the external device to handle the command
  • read com input and insert answer from the device in the listbox

 

Regarding the selection of the COM port, it's not clear to me wether you want to have a list of available ports or simply let the user choose a value from 1 to 32 and open the corresponding port. In the first case the dll published by msaxon in this thread maybe of some help to you.

Message Edited by Roberto Bozzolo on 02-25-2009 12:11 AM


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 13
(4,391 Views)

Thanks Roberto.

This is a great starting point.

 

As for the COM ports there are two 16 port USB serial servers for a total of 32 COM ports. Depending on which server is pluged-in (discovered) first will change the COM mapping on the PC not to mention if there are any other USB serial devices connected to the PC. The plan is to be able to select any of the Serial Server COM ports only and they will be labeled in the LabWindows/CVI UI for example:

 

TA232 =Serial Server Port 1 = PC COM4

TB232 =Serial Server Port 2 = PC COM5

TC232 =Serial Server Port 3 = PC COM6

TD232 =Serial Server Port 4 = PC COM7

.

.

.

The Serial Server port mappings will not change but the PC COMx mapping could change depending on which order the USB cables are discovered. In the LabWindows/CVI UI I want to name the buttons that select the COMx ports as TA232 etc.

I don't know if this will be possible?

0 Kudos
Message 7 of 13
(4,385 Views)

You could have a button "Scan for COM ports..." that scans the available com ports in the system and populates a ring control with only active ports: let the user select the appropriate one and press a "Start communications" button to actually open the selected port.

 

Regarding the port scan, I remember to have read in the forum several solutions to this task:

  • Place a loop that iterates on all 32 ports and tries opening each of them, excluding those on error from the list: there are some caveats though on finding ports that are not actually operable like internal modems in laptops an so on
  • Use msaxon dll
  • Use VISA that should have a way to enumerate resources (not sure: never used VISA for serial communication)

Make a search in the forum for these subjects.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 13
(4,374 Views)

Is there a way to configure the serial com port receive to act like a received character interrupt routine?

I want it to automatically immediately stuff a received character into the rx_buff and also a display text box so I can see the data as it arrives.

The Help file did not mention this? A programmers reference would be nice but I don't think it exists.

0 Kudos
Message 9 of 13
(4,343 Views)
You could try installing a callback on the com port: look at InstallComCallback routine with LWRS_RECEIVE event mask and 1 in notifyCount parameter: the callback is fired on every character received. You must be *fast* in handling the callback oryou may miss some character (the callback is not fired again if a new character is received when it is still executing).


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 10 of 13
(4,338 Views)