Makeblock-official / PythonForMegaPi

python for MegaPi with Raspberry Pi
http://openlab.makeblock.com
49 stars 26 forks source link

Suggestion for improved compatibility #16

Open WrickColl opened 5 years ago

WrickColl commented 5 years ago

Python and Node.js should be basically interchangeable so that users can investigate the qualities of both languages easily. Currently one has to modify the /boot/config.txt file and reboot to change over. This is because the two languages solved the serial device naming change differently. If all references to the serial communication on pins 14 and 15 are changed to "/dev/serial0" instead of /dev/ttyxxx in both languages then everything will be compatible between different versions of Raspberry Pi and between Python and Node.js. For Python this change needs to be made in the "megaPi.py" file, and remove the advice about swapping the ports in the README. For node.js it is done by the user so all example programs should be modified. Also the user just needs to add "enable_uart=1" to their "/boot/config.txt" file. I have made these changes to my own copy of the files and now I can can swap between languages directly without reboot or any fuss.