Hi, I am trying to figure out a way to reboot the Adafruit feather (Adafruit Feather M0 RFM95) though bash command.
The functionality of the Arduino sketch is something like this. It transmits 4 beacon signal and then calls exit(0); in order to stop the loop().
Till now, after every experiment I used to press the reset button on the board in order to reboot the feather so that it could start sending the beacon signal again but now I am looking for a way in which I can do it without physically pressing the reset button as I will be remotely accessing the system it is connected to.
I am trying to use void(* resetFunc) (void) = 0; which is mentioned in the Arduino documentation i found.
I figured that I will have to get rid of exit(0) in order to call resetFunc so now I am using a flag variable which changes after the feather transmits 4 beacon signal.
I am doing something like this to call the resetFunc
void loop()
{
if (Serial.available() > 0) //to get input from bash
{
chr = Serial.read();
Serial.println(chr);
if (chr == 'R'){
resetFunc();
}
}
But when I run echo 'R' > /dev/ttyACM0, the feather does not reset. Can someone help me with this? Any suggestion and help is appreciated.
What do you want to achieve? Standard procedure instead of Reset is to put the controller in sleep mode and let it wake up on some external event, like Serial input.
I don't know what the controller makes after exit(0) - do you?
The setup is in a lab and I want to access it from my home plus I have to save the signal to a file for which I am using software defined radio so yes, the Arduino is connected by a serial port and I am accessing the system through Team Viewer for now.
I am fairly new to Arduino but from what I learned is exit(0) stops the program from running but puts that process running in an infinite loop. That's why after the program hits exit(0), I cannot do anything else.
Now, why am an trying to reset the board though BASH command is because I want to run multiple tests in which 1 AP will be transmitting beacon signal and on receiving them other nodes will start transmitting and I have to save the trace using a SDR.
This is one test run. I want to do multiple runs so I am trying to find a way in which I can reset the AP's board and run the SDR at the same time.
Its not difficultl to have an Arduino listen to its serial port, with a timeout, for a 'unique' string of bytes and when they are recieved carry out a particular function.
I think that you should forget about running processes on a PC until they exit. On a µC a single process runs in a loop and there it can do something or nothing depending on some condition.
If you prefer the batch approach: write a shell that runs on the Arduino which you can ask to start your process. The shell can be as simple as to wait for a specific ('R') command character.
It would be interesting if you simply connected a digital output to the reset pin, never tried it.
Or perhaps you could have a small mosfet driving the reset, not sure why it would be different except there will be a higher gain.
Your board seems to have native USB capabilities. In that case opening and closing the serial port with a baudrate of 1200 baud will probably work.
If you enable verbose output during upload in file -> preferences, you will probably see something like
Sketch uses 3954 bytes (13%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port COM23