<commit_before># Compile and load

Arduino code is compiled and load using:
* platformio: a builder tool for embedded system
* the pololu programmer

1. First, plug the pololu programmer to your board (see Table of Contents for  Practical AVR Microcontrollers: Games, Gadgets, and Home Automation with the Microcontroller Used in Arduino, chapter 2).
2. Then, plug it using a mini-USB to USB cable to your computer.
3. Then power the board with 5v (using a battery or a USB-to-TTL circuit)
4. Identify the port on which the pololu driver is plugged ([reference](https://www.pololu.com/docs/0J36/5.b)):
  a. on OS X, type
  ``` shell
  ls /dev/cu.usb*
  ```
  THe lower number indicates the port on which the programmer is connected
  b. on Linux: TODO
  c. On both platform you can also use:
  ``` shell
  platformio device list
  ```
5. Configure the PLATFORMIO_UPLOAD_PORT environment variable:
``` shell
export PLATFORMIO_UPLOAD_PORT=/dev/cu....
```
Note that platformio can also automatically detect the port, but don't rely on it.
6. In the project folder (i.e. in magsensor folder) Upload the program:
``` shell
make pololu
```

Bonus: To get the status of the programmer, run `make pololu`, and copy-paste
the avrdude command without the `-U firmware` option.

# Serial communication

When pluging a USB-to-TTL serial line to the Atmega328 (with Atmega RX to
USB-to-TTL RX and Atmega TX to USB-to-TTL RX), connect to the serial port:
1. On OS X, using:
``` shell
screen /dev/????? 9600
```
speed (9600) can vary depending on the atmega configuration.<commit_msg>Add doc for running platformio in VM+docker<commit_after># Compile and load

Arduino code is compiled and load using:
* platformio: a builder tool for embedded system
* the pololu programmer

1. First, plug the pololu programmer to your board (see Table of Contents for  Practical AVR Microcontrollers: Games, Gadgets, and Home Automation with the Microcontroller Used in Arduino, chapter 2).
2. Then, plug it using a mini-USB to USB cable to your computer.
3. Then power the board with 5v (using a battery or a USB-to-TTL circuit)
4. Identify the port on which the pololu driver is plugged ([reference](https://www.pololu.com/docs/0J36/5.b)):
  a. on OS X, type
  ``` shell
  ls /dev/cu.usb*
  ```
  THe lower number indicates the port on which the programmer is connected
  b. on Linux: TODO
  c. On both platform you can also use:
  ``` shell
  platformio device list
  ```
5. Configure the PLATFORMIO_UPLOAD_PORT environment variable:
``` shell
export PLATFORMIO_UPLOAD_PORT=/dev/cu....
```
Note that platformio can also automatically detect the port, but don't rely on it.
6. In the project folder (i.e. in magsensor folder) Upload the program:
``` shell
make pololu
```

Bonus: To get the status of the programmer, run `make pololu`, and copy-paste
the avrdude command without the `-U firmware` option.

# From a VM

Make sure the pololu device is not caught by the host by configuring you VM software.

# In docker

If you are programming your arduino from docker:
1. Execute the command with root user (using sudo)
2. Launch the container with the specified device:
```
docker run --device=/dev/ttyACM0 --device=/dev/ttyACM1 -it -v /home/jedi/projects/domos/:/home/jedi/domos arduinodev bash --login
```

/!\ Note that the device need to be plugged

# Serial communication

When pluging a USB-to-TTL serial line to the Atmega328 (with Atmega RX to
USB-to-TTL RX and Atmega TX to USB-to-TTL RX), connect to the serial port:
1. On OS X, using:
``` shell
screen /dev/????? 9600
```
speed (9600) can vary depending on the atmega configuration.
{'fraction_non_alphanumeric': 0.08628318584070796, 'fraction_numerical': 0.014380530973451327, 'mean_word_length': 3.9010840108401084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4692855', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1092, 'n_words': 531}