Logging of serial port data


edh

Recommended Posts

Hi,

We have used the comm monitor to troubleshoot some connection issues but it is limited in that we can only really see and capture a small amount of data at a time as we are streaming a lot of data through it.  What we really need to be able to do is log down raw serial data over many days to be able to prove and debug our application in long term testing before we can release it.

This can't be a unique requirement so does anyone have any experience in doing this?  I was really considering three potential routes:

1. Does DAQFactory have some kind of built in debugging mode that logs all raw data?

2. Can we code a sequence to do this?

3. Use a 3rd party utility.  I have tried a few that suggest they can be used for serial port sniffing and can't get any to work as expected but perhaps someone has some ideas of something known to work.

Link to comment
Share on other sites

1) No, though that would be pretty easy to implement so I'll add it to the wish list. 

2) you could provided the data isn't coming in too fast.  I'm not sure what too fast would be, but it might only be a problem at 115k baud or higher.  Anyhow the script goes something like this:  

private handle = file.open("c:\data\myFile.dat",0,1,0,0)
private string datain
while(1)
   try
      datain = device.myDevice.read(480)
      file.write(handle, datain)
   catch()
      delay(0.05)
   endcatch
endwhile

A few points:


1) obviously change the file name to what you want. Also, change myDevice to your device.

2) the 480 in the read is a bit arbitrary.  If the data is continuously streaming you want a number that equal to about half the number of characters that would arrive in the timeout period.  So, if you were, say, at 9600 baud 8,n,1 you are talking 10 bits per character, or 960 characters per second.  If the timeout is 1000ms, then 480 is probably appropriate.  If your data is faster, then you'd need a larger number.  I believe the internal buffer is 10000 characters, so you should probably not go above 8000 or so

3) the data is going to be logged in binary.  Converting it to an ASCII representation would be too slow for anything but the slowest baud rates.  Use a binary editor to view the data.  Visual Studio for example

4) The above will work for ASCII as well and will write everything that comes in.

5) I did not test this....  Make sure and save before you start the sequence.
      

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.