Skip to content

Running the example program

Ken Tindell edited this page Apr 6, 2017 · 4 revisions

The example program comes in two parts:

  1. The target part runs on an Arduino board with SerialUSB support (An Arduino M0 Pro was used in testing).
  2. The host part runs in Python on a host PC with Pyserial support.

To run the example program, connect the target board to the host with two USB cables: the programming cable to load the sketch and display the serial monitor (debug messages will appear here) and the native USB port (over which MIN runs).

From inside the Arduino IDE check where the serial ports are mapped to. A MacBook was used for development and the programming port was mapped to /dev/cu.usbmodem51 and the native USB port mapped to /dev/cu.usbmodem1421. The sketch is in target/sketch_example1. The include paths for min.c and min.h will need to be set.

Edit the Python code in listen.py and change MIN_PORT to match (it should be at /dev/tty.usbmodem1421 or similar). While the Arduino code is running, open a terminal, cd to the host folder and run:

$ python3 listen.py

The port should open and this should then let the target Arduino board continue initializing and run. The target board will send a MIN frame every second to the host, and the host will send a MIN frame to the target (which will get echoed back). There are diagnostic print statements in both target and host programs that will indicate progress. On the PC end it should look something like:

Frame received: min ID=51
(Time = 1798676)
Frame received: min ID=2
(In ASCII: 'b'hello world 1490026631.661187'')
Frame received: min ID=2
(In ASCII: 'b'hello world 1490026632.162867'')
Frame received: min ID=51
(Time = 1799688)

On the Arduino board in the serial monitor (set to a baud rate of 115200) it should look something like:

MIN frame with ID 1 received at 1864351
MIN frame with ID 1 received at 1865353
MIN frame with ID 1 received at 1865359
MIN frame with ID 1 received at 1866360
MIN frame with ID 1 received at 1866366
Clone this wiki locally