Hi! I'm working in a application to communicate with my Arduino from Python (using USB interface). It's working on the Arduino UNO. Now I want to make it work on a Mega, and I'm facing a problem: the Mega has many more things that the Uno. If a Python program is written for a Mega, but connected to an Uno, it should report an error!. Or work until the Python program try to use something that the connected Arduino doesn't have (I mean, let it work if the program try to use digital pin 1 to 13, but raise an Exception if try to use digital pin 20).
One possible solution: is there any way to check if the hardware has a given port? I would like to do something like:
if(digitalPortExists(99)) {
// OK. It's safe to use digital port 99
} else {
// Send ERROR message to PC.
}
Another way would be to send, from the Arduino, what kind of Arduino the program is running on. With this information, I would be able to do the check in Python. And I think this would be better, since knowing the Arduino model, I would be able to check digital and analog pins, what pins have support for PWM, how many interrupts, etc. Something like:
char* model = getArduinoMode();
Serial.write(model);
The project I'm working on is at GitHub - hgdeoro/py-arduino-proxy: [renamed to py-arduino] Communicate with Arduino from Python (DEPRECATED! Please see py-arduino). The project is a "low level" communication library, but I've crated a simple UI to better illustrate the possibilities:
Thanks in advance!
Horacio