Guest User

Untitled

a guest
Jan 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. dev = DeviceOpen["Serial", "COM4"]
  2.  
  3. parseData[{val1__, 9, val2__, 9, val3__}] :=
  4. ToExpression@FromCharacterCode@# & /@ {{val1}, {val2}, {val3}}
  5. parseData[___] := Sequence[]
  6.  
  7. rawReadings = {};
  8. task = SessionSubmit[
  9. ScheduledTask[
  10. AppendTo[rawReadings,
  11. Flatten[{Now,
  12. DeviceReadBuffer[dev, "ReadTerminator" -> 10]}]], {1, 20},
  13. "AutoRemove" -> true]]
  14.  
  15. ListLinePlot[Transpose[parseData /@ rawReadings],
  16. PlotLegends -> Automatic] // Dynamic
  17.  
  18. DeviceClose[dev]
Add Comment
Please, Sign In to add comment