LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine serial interface type, 485 or 232

Solved!
Go to solution

My idea was

 

set "wire mode" to RS485/wire2-auto, if gave an error, it was a 232 interface. change value to RS232-auto, connect and go on

or

vice-versa

AC

0 Kudos
Message 11 of 15
(1,644 Views)
Solution
Accepted by acardoso

From the NI-VISA Help (note the part that I bolded):

 

VI_ATTR_ASRL_WIRE_MODE

VI_ATTR_ASRL_WIRE_MODE represents the current wire/transceiver mode.

 

For RS-485 hardware, this attribute is valid only with the RS-485 serial driver developed by National Instruments.

 

For RS-232 hardware, the values RS232/DCE and RS232/AUTO are valid only with RS-232 serial drivers developed by National Instruments and documented to support this feature with the corresponding National Instruments hardware. When this feature is not supported, RS232/DTE is the only valid value.

 

RS-232 settings:

  • VI_ASRL_WIRE_232_DTE uses DTE mode.
  • VI_ASRL_WIRE_232_DCE uses DCE mode.
  • VI_ASRL_WIRE_232_AUTO automatically detects which mode to use.

RS-485 settings:

  • VI_ASRL_WIRE_485_4 uses 4-wire mode.
  • VI_ASRL_WIRE_485_2_DTR_ECHO uses 2-wire DTR mode controlled with echo.
  • VI_ASRL_WIRE_485_2_DTR_CTRL uses 2-wire DTR mode controlled without echo.
  • VI_ASRL_WIRE_485_2_AUTO uses 2-wire auto mode controlled with TXRDY.

 

Now, can we get back to why you're trying to do this in the first place, which you have yet to explain? There may be an easier way to solve whatever problem you are trying to solve.

0 Kudos
Message 12 of 15
(1,636 Views)

As the previous post asked, what are you trying to do, on the highest level, not at the level of checking what type of port, but why do you need to? Are there instances when you may be running on a system with RS232 or 485? What type of com interface are you using, one that can switch modes? If so, the wiring mode "stuff" is only for National Instruments' devices. The wire mode, when used with NI hardware, tells you, in RS485, whether you are setup for 2 wire (half-duplex) mode, or 4 wire (full-duplex) mode, but doesn't really tell whether you have 232 or 485 (do a LabVIEW Help on Serial Instr).

 

If it is a non-NI serial adapter that can be used in different modes, the ones (SeaLevel brand)  I have used make use of a change in the registry to both change the serial port configuration, and by reading the value in the registry, determine what mode a port is in.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 13 of 15
(1,633 Views)

Why would you even try to change a port from 485 to 232 in software? The software side of the port doesn't care whether it is 232 or 485.  But it definitely matters on the hardware side as the wiring implementation between an RS-232 port vs. a 2-wire RS-485 vs. a 4-wire RS-485 are completely different.  You can't change the type of port it is without physically changing the wiring to it.  And if the port is configurable, than it is usually changed either by jumper settings physically on the card, or possibly by a setting in the actual driver.  What brand/model of serial ports are you using?

 

Also, please don't have your user icon linked to an offbeat 3rd party website  paginas.fe.up.pt   It makes the page take forever to load and just winds up looking like a red X, anyway.  Post the image file to this thread or to your image gallery and have your icon point to the attachment based on the NI website.

0 Kudos
Message 14 of 15
(1,619 Views)

Actually, I had to build a test system, exactly one year ago, where the unit under test had software reconfigurable comm ports, RS232 to 485. The software talking to a port may care little if they are one or the other (although 232 provides a lot more variables in handshaking/control lines), but there are software configurable ports that can shift modes. In my case the UUT could be installed in a number of different configurations, depending on their customer's needs, some with 232, some with 485 hookups. My test system had to test them in their different configurations, so it implemented a relay system to change the requisite wiring configurations, and then changed the tester side port configuration through software. The boards, from SeaLevel, can be "software configured", but it turned out that was through device manager, "manually" changing the port from 232 to 485 or vice versa. Not an option in an "automated" test system. I determined that changing the port in DM actually changed settings in the Registry, so that is what I had my code do, send a configuration command to the UUT, then change the registry (scary, don't like messing with the registry!!!), the do the test.

 

So that is why I ask the original poster what is trying to be accomplished, why does he need to know what mode a port is in.

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 15 of 15
(1,606 Views)