Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers.

Hard serial binary data

0 votes
I'm writing a module to calculate motion data from images.   I would like to send results over the hardware serial, but as binary data, not a text string.  I have quite a lot of data, which fits in a 115200 connection, but would not in text form.

I have tried to instantiate the jevois::Serial class, guessing as I go along, since there is not a single example that shows how to do this.  I created a member variable of this type in my module, and constructed it with the module instance:


then, in my process, I use the write method to send a binary buffer.  This doesn't work, and my video output shows that an       std::exception was thrown with an error:    Serial: write error

Can anyone point to how the proper usage is, without using the text based  sendSerial method of the engine, or is that the only way, and the Serial class is not for use directly by modules?

Self comment:  Looking at the source code for the engine, I suppose I could hack an interface that exposes the Serial object and use that, but I would rather use a ready made approach, before hacking the engine code.
asked Aug 14 in Programmer Questions by Photon (320 points)
edited Aug 14 by Photon

1 Answer

0 votes

(sorry for the delay as we are just back from vacation)

You may need to first make sure that the Engine does not open the port, by disabling it there:

in JEVOIS:/config/params.cfg add this line:


The empty device name will tell JeVois to not open the hardware serial port. Then indeed you can create your own in your module, but you need to add it as a sub-component rather than just using a member var, so that your serial will be integrated to the component hierarchy and its parameters will be available to users, etc:

in your module's class, declare a shared_ptr member var:

std::shared_ptr<jevois::Serial> m_serial;

then in your module's constructor:

m_serial = addSubComponent<jevois::Serial>("myserial", jevois::UserInterface::Type::Hard);


Then you should be ok with using m_serial->write() for raw data writes.

some more infor about components hierarchies in jevois is here:


answered Aug 18 by JeVois (11,490 points)