Shop OBEX P1 Docs P2 Docs Learn Events
automating serial debug — Parallax Forums

automating serial debug

max72max72 Posts: 1,155
edited 2010-07-12 13:49 in Propeller 1
I would like to ask your opinion about the following:
Sometimes I would like to be able to test an object or an algorithm using test data. I would like to simluate sensor reading using known values.
In my mind the ideal solution would be a scripting language (say Perl, or anything else) feeding the propeller with data using the serial port, taken from a text file, and reading and storing back the propellered data in another text file. This way I would be able check the data using a spreadsheet, scilab, octave, or anything else.

Any suggestion is welcome.

Massimo

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-12 13:15
    What you suggest is not a bad idea, but it may not be as useful as you think. The issue is that most sensors don't produce asynchronous serial data. They may produce an analog signal or use the SPI or I2C protocol to provide the data or perhaps produce a timed pulse or something like that. In order to insert test data, you'd need to modify the I/O routines involved to provide for that and any testing you'd do would not test the interface to the actual sensor. That's not a bad thing, but it leaves a lot of the code out of the testing process so you're really just testing the high-level algorithm and none of the code that has to do with the actual sensor itself.

    Do have a look at Hanno's ViewPort (hannoware.com/) which does something similar at a lower level. It uses a serial port for communications, but it uses code on the Propeller side, running in its own cog, to directly affect or monitor the I/O pins.
  • max72max72 Posts: 1,155
    edited 2010-07-12 13:49
    Thanks Mike.
    Somethimes I have the sensor handling working, but I'm not sure the calculations are bullt proof. Assuming I can handle and pre-process sensor data, I would like to test my algorithms against a series of test data.
    For instance:
    I have a GPS and an anemometer, and I'm sure the serial handling works.
    I'm not sure my trig functions are ok, I'm not overflowing, I correctly handle sign and roll over.
    My output data would be true vind and VMG, or with a set of GPS data I would expect way point data /distance, VMG, time to target, in case of a line XTE, time to line and so on..
    If I can feed the propeller with fake data, let's say a set of speed/heading, and check it back against my expected data, I would be able to verify part of my code, independently of the sensor protocol.
    In my understanding Viewport can change a data set, but not iteratively doing that.
Sign In or Register to comment.