0
votes

I am controlling a device over serial connection using LabVIEW (version 7.0). It is connected using USB, and is installed as a virtual serial port on the computer (running Windows XP). Every now and then my device crashes when my program sends a command, and it is unable to accept any more input (the device itself also stops working) until it has timed out.

I've looked at the serial port traffic using Portmon. Whenever the device crashes the serial driver sends the command I send using my program four times instead of just once, with an IOCTL_SERIAL_GET_COMMSTATUS command in between. I cannot see what this last command returns, but I assume something happens in the communication earlier on. I'm thinking my configuration of the port is not entirely right, but I have no idea how or why. I open and close the connection to my device every time I want to write something to it.

For completeness' sake: it has a baud rate of 9600, 8 bits, no parity, 1 stop bit, and no flow control. I'm aware that the correct settings of these parameters depend on the device, but the manufacturer has not supplied any recommended settings.

1
In addition to Portmon, you can also get the LabVIEW perspective of the serial communications using NI I/OTrace -- digital.ni.com/public.nsf/allkb/… . Lines that appear in red indicate error conditions.Joe Friedrichsen
In order to help you, you need to supply more specific information. What device are you connecting to, what driver do you use and can you post an excerpt of your labview code, even though as suggested it might not be the problem. Do you have another program that does not have this problem using the same driver.D.J. Klomp
@D.J.Klomp Specifically, the device is an RF generator (made by WindFreak, the model is SynthUSBii). It contains an ATmega32U2 microcontroller. As I've described below, adding a carriage return to every command solved my issue, so it does not depend on the program that controls the device. I realize that this problem may be a bit too specific to be treated here, since I guess it depends quite strongly on how the microcontroller is programmed.Julius
Nice that your problem is solved. Seeing this solves the problem I would guess that you use the wrong termination character. Labview standard uses a linefeed (\n or 0xA) as termination character. Try to switch this to the carriage return character (0xD) and see if you don't need to add the extra CR. Some serial devices require a linefeed and carriage return to be send. Than you way of doing it is correct since labview doesn't support sending multiple termination characters.D.J. Klomp

1 Answers

0
votes

The driver is a DLL of some sort? If so, this is the most likely source of your problem, and you likely will need to contact the author of the driver. LabVIEW does have crashing bugs, but by far the most common source of crashes in simple communications apps is a buggy third-party DLL.

In other words, I doubt this is a LabVIEW problem at all and that you would have the same difficulty if you wrote a C program to talk to this driver. I only know what you've posted here about your system, but after many years of chasing down such issues, I would start with the device manufacturer/driver author.

If you have evidence to the contrary, please share.