Raspberry Pi serial port as an interface
You can solder a 2x5 socket on NyBoard to plug in a Raspberry Pi. Pi 3A+ is the best fit for NyBoard's dimension.
As shown in the serial protocol, the arguments of tokens supported by Arduino IDE's serial monitor are all encoded as Ascii char strings for human readability. While a master computer (e.g. RasPi) supports extra commands, mostly encoded as binary strings for efficient encoding. For example, when encoding angle 65 degrees:
- Ascii: takes 2 bytes to store Ascii characters '6' and '5'
- Binary: takes 1 byte to store value 65, corresponding to Ascii character 'A'
Obviously, binary encoding is much more efficient than the Ascii string. However, the message transferred will not be directly human-readable. In the OpenCat repository, I have put a simple Python script ardSerial.py that can handle the serial communication between NyBoard and Pi.
In Pi's terminal, type
Under the Interface option, find Serial. Disabled the serial login shell and enable the serial interface to use the primary UART:
- 1.Run raspi-config with sudo privilege:
- 2.Find Interface Options -> Serial Port.
- 3.At the option
Would you like a login shell to be accessible over serial?select 'No'.
- 4.At the option
Would you like the serial port hardware to be enabled?select 'Yes'.
- 5.Exit raspi-config and reboot for changes to take effect.
If you plug Pi into NyBoard's 2x5 socket, their serial ports should be automatically connected at 3.3V. Otherwise, pay attention to the Rx and Tx pins on your own AI chip and its voltage rating. The Rx on your chip should connect to the Tx of NyBoard, and Tx should connect to Rx.
If you want to run it as a bash command, you need to make it executable:
chmod +x ardSerial.py
You may need to change the proper path of your Python binary on the first line:
./ardSerial.py <args>is almost equivalent to typing <args> in Arduino's serial monitor. For example,
./ardSerial.py kcrFmeans "perform skill crawl Forward".
Both ardSerial.py and the parsing section in OpenCat.ino need more implementations to support all the serial commands in the protocol.