[Interest] Is there a way to simulate serial port data?

Stéphane Fabry sf at xris.eu
Wed Mar 29 09:15:44 CEST 2017


You can also simulate via external software like https://docklight.de/

or create serial port pairs (search for virtual serial port)


Le 28-03-17 à 13:42, Murphy, Sean a écrit :
>> First of all your parsing class should only do the parsing, so it
>> shouldn't derive from QSerialPort.
>> instead it should take a QSerialPort pointer as a parameter, eg:
>> QSerialPort port(...);
>> port.open(...)
>> Parser parser(&serialPort);
>> Result result = parser.parse();
>> or
>> Parser parser;
>> parser.setSerialPort(&port);
>>
>> This way, you could then derive QSerialPort into a VirtualSerialPort,
>> and use it this way:
>> VirtualSerialPort port(...);
>> port.setData(byteArray);
>> port.SetSomeConfigurationParameter(...);
>> parser parser(&port);
>> Result result = parser.parse();
> I agrees, this seems like a much better approach in the long run.
>
> The issue at the moment is that it's 3 year old code that really could use to be refactored, but the current schedule doesn't allow for that. Right now I'm chasing down a bug that has only affected us a dozen times or so over 3 years, so it's tough to justify ripping up all of the serial port stuff right now, but it needs to be done at some point. But for the short term, I was hoping I could find a way to simulate data coming in on the serial port so that I can concentrate on the existing bug, without modifying the existing codebase.
>
> Sean

-- 

*Stéphane Fabry*, R&D Manager & Software architect
+32 (0)4 367 07 92
*X-RIS* | /X-Ray Imaging Solutions/
www.xris.eu/contact.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170329/3d141bcf/attachment.html>


More information about the Interest mailing list