Capture Incoming Data


Andre

Recommended Posts

I am working on a new project and need to capture data from the Comm monitor after triggering the device to dump the data. I have two triggering options.

Option 1

Device.DeviceName.SetRegisterS16(247,103,1)

Option 2

device.DeviceName.Write(chr(1))

 

Is there any way I can capture the incoming data? The data will need to be loaded into an array. In total 94 values will be dumped.  

Link to comment
Share on other sites

Here is an example of the data that is generated from the device.

Tx: \001
Rx: \076\097\115\116\032\080\097\103\101\032\114\101\099\111\114\100\101\100\032\032\049\048\032\111\102\032\050\048\052\055\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013\078\111\032\068\097\116\097\032\010\013

Link to comment
Share on other sites

That is all ASCII data.  Uncheck the box in the monitor that says "Display ASCII chars as codes" and you will see.  To capture the data, just do a bunch of readuntil(10) commands until it times out, then stick the result of each into a string or wherever else you want.  I see multiple lines of ASCII data, so readuntil(10) will work a number of times, then when done it will time out.  If the response is always a certain number of lines, you can repeat readuntil(10) that many times in a for() loop, and then stop.

You should probably do a purge() before doing the write() to trigger the response.

 

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.