Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers. Note that due to large amounts of spam attempts, your first three posts will be manually moderated, so please be patient.
We have moved to a new forum at http://jevois.usc.edu, please check it out. The forum at jevois.org/qa will not allow new user registrations but is maintained alive for its useful past questions and answers.

Sending commands from python to serial command line

0 votes
Hi,

I am trying to find a way to send a command to the serial command prompt from within the PythonTest module. I saw that there is the command jevois.sendSerial(), but this just sends the text as a message to the command prompt. Is there a way to send  text to the serial command prompt (like listmappings) from within a module where the camera will treat it as a command and try to execute it?
asked Jan 30, 2020 in Programmer Questions by obriena (310 points)

1 Answer

0 votes

This is not supported. Just to give you the historical background: we started with a C++ core framework. In there, all one can access, from within a vision module, all core functionality (like list the mappings, etc) by calling the appropriate functions on the JeVois Engine object (which is always at the root of a vision pipeline). Then we added the command-line interface as a way for the host computer to also access some of the core functions, over a serial port. Finally we added python support on top of the C++ core, with some direct bindings from the core to the Python side of things, shown here:

http://jevois.org/doc/ProgrammerPython.html

(see section on Python bindings provided by jevois core).

Now we did not provide a python binding for something like listmappings because a vision module (the python code you are writing) should not need to know that. It should work just for whatever mappings it can support, and the host computer is in charge of picking a mapping (and hence a vision module) it wants to run. If listmappings is indeed what you want, then can you tell us why you would need it? From within a vision module, you should never have to worry about that list. If you want something else, maybe we can add a python binding for that?

In the meantime, the best way to quickly solve your problem is to have your host computer issue some commands to the jevois command-line interface, for example like here:

http://jevois.org/tutorials/UserPanTilt.html

if you scroll down to the first piece of source code, line 43 the Arduino sends this to the JeVois camera:

SERIAL.println("setpar serlog None");

to configure it.

Or in this one:

http://jevois.org/tutorials/UserColorTracking.html

some python program running on the host sends some commands to JeVois as the sliders in the Python GUI are moved around.

answered Jan 30, 2020 by JeVois (46,580 points)
Hi,
Thank you so much for the in depth reply. I was just using listmappings as an example of a command for my question; I am not trying to run that specific command from within the module. Basically, what I am trying to accomplish is to make a keyboard shortcut to run a .cfg script that I added to the module folder. In PythonTest I added a script named detect.cfg. I was trying to see if there was a way to have it so the user just needs to enter the letter "s" into the command line interface to run the script, rather than having to type out “runscript detect.cfg”. If that isn’t possible that's fine; this was more of a convenience feature I was trying to add. I'll check out the links to the docs you provided.

Thanks again for the reply.
...