Is there any update as to this functionality? Given that I have a jetson nano on a VEX V5 robot, there is a fool-proof way to start the nano (via sending a serial connection to it upon robot code run). However, I do not have a fool-proof way to send a quick shut-down message when the red button is held on the controller.
Perhaps I can do a “hey are you there” message every x seconds to the nano but like what if I need the V5 Brain to manage certain components (like close a lid or set pneumatic state beforehand)?
Not much has changed. The user program can request it is stopped using brain.program_stop(), but there is no way to detect that the program is being stopped by vexos.
Sylib has a piece of code running in a daemon to detect when the center button is pressed to exit the program and turns off the LEDs. I haven’t found this to be completely reliable but maybe something similar will work in your case. code below can be found here, lines 162-179.
Yes, there’s probably a way to detect center button press in VEXcode as well, but that doesn’t help if the program is stopped on the brain or remotely.
Thank you for your time, it means a lot. Does the V5 Brain emit a certain serial through micro USB when a program stops, since you can start and stop programs via the VSCode extension?
Not sure this is the route you want to go down, but…
The serial protocol used by the brain and controller does have a packet for programatically starting/stopping files loaded to flash (programs), but there’s no packet sent by the brain for when a program has been stopped by the user, so what you’re specifically asking about doesn’t exist, no.
That being said, you could monitor the currently running program over USB and detect when that value changes by polling it. I don’t think that would be of any use to you if you’re attempting to stop a solenoid through user code though, since the program would have already exited.