LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i sniff an RS232 connection and write the content to a file?

I use a VI to sniff an RS232 and I want to log the results to a textfile. The program is built around a while-loop

that constantly reads from the serial port. I've tried defferent variations,but either I overwrite the contents of the

file with every iteration, ending up with a log of only one byte, or I'm asked to make a new file for every iteration.

0 Kudos
Message 1 of 26
(4,080 Views)

Well, without seeing your code we cannot tell you what's wrong. We can guess, but there's too many possibilities.

 

You should consider just using a tool that designed to do serial port sniffing, such as PortMon, or other similar utility. Do the Google, and you should come up with a bunch of results.  Smiley Wink

0 Kudos
Message 2 of 26
(4,077 Views)

Below is an example of a simple file write. There are numerous methods for writing to a file and you did not mention what functions you are using. If the code below is not what you want, please post what you've written.

 

Message Edited by Dennis Knutson on 11-05-2008 08:17 AM
Message 3 of 26
(4,073 Views)

When inserting the write-object inside the while-loop like that the program will try to create a new file in every iteration.

 

I try to include my code in my posting, but I can't figure out how it's done. It is attatched.

0 Kudos
Message 4 of 26
(4,033 Views)
Do you want to sniff your own LabVIEW application, or another?

If you want to sniff another application, you're better off searching the
web for serial sniffers. Writing this yourself will be challenging. You'd
probably need to write your own device drivers. Or simply wire the serial Tx
and Rx to another port could work in some cases (at your own risk).

Regards,

Wiebe.


0 Kudos
Message 5 of 26
(4,031 Views)
I want to sniff something else, which is not a LabVIEW application.
0 Kudos
Message 6 of 26
(4,029 Views)

Should this really be that hard? I can get the data to show in a read buffer (which

obviously flicker away to fast for me to read). All I want to do is log it. This should be

possible if I could just connect the file writing objects properly.

0 Kudos
Message 7 of 26
(4,015 Views)

It isn't that hard. why don't you try writing something like I posted. Your VI is fatally flawed. You have the write file outside the loop where you will only write one result. And even if you move it inside the loop, you don't have the file path from the File Dialog wired up. Have you looked at any of the shipping examples?

 

0 Kudos
Message 8 of 26
(3,992 Views)

I have rewritten it a little, using Set File Position and putting the Write File inside the loop. Now it will only ask for a file name twice. If I enter two different names the first one will be forgotten; no file by that name is created.

 

The sniffing aspect is also working poorly. This used work, but for some reason it doesn't do that anymore. The return count constantly shows zero and the log files that actually are created are filled with nothing but zeroes.

0 Kudos
Message 9 of 26
(3,982 Views)
Of course you get two prompts for a file name. You've got the File Dialog function that asks you and because you have not wired the path output to the Open file function, the Open File function is going to ask you for a path as well. I told you about this problem in my previous answer. And as another word of advice, don't create your own numeric constants to wire to the file functions. Right click on the input to the function and select 'Create Constant'. Not only will you get the correct data type, you will get an enum that you can visually see what the option is.
Message 10 of 26
(3,971 Views)