Passing null protocol Comm data into variables


Bardownski

Recommended Posts

Hi,

I am looking for some scripting help.

I have data properly passing through the Comm port with a null protocol. (see image below) 

The data is repeating (100 ms) in 13 byte intervals with no carriage return. The data in the first Byte (\x86) is a constant.

I am trying to pass this data into variables in DaqFactory which I can display/log/etc.

Most of the help I have found uses the "device.myDevice.readUntil()" which I have been unsuccessful at using 

Would someone be able to push me in the right direction?image.thumb.png.4ca230732853eab28551be8619cd16d1.png

Thank you in advanced. 

Link to comment
Share on other sites

Actually, readuntil() would probably be the best choice.  You'll want to readuntil(0x86), then make sure you have 13 bytes, then parse it, so something like:

private string in
private bin
while(1)
   in = device.mydevice.readuntil(0x86)
   bin = asca(in)
   if (numrows(bin) != 13)
      continue
   endif
   // now you can parse bin, which is an array of numbers.  Note that 0x86 will be at the end, not the beginning.
endwhile

Two notes:

1- I actually have forgotten if readuntil() also returns the value you are reading until, so the returned length might be 12 and no 0x86 at the end.

2- you do not need a delay() inside this loop, though you may want to add one (delay(0.1)) right after the while() until you are sure you don't have any typos.  You don't need the delay() because DAQFactory will essentially delay on its on while doing the readuntil().  If you introduce a delay that causes DAQFactory to loop slower than your device is spitting out data, it will fall behind.  

 

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.