Is there a way that I can assert/unassert the pins on the COM port (serial port) from Simulink without being have to open and close the port every time?
Scenario: I have a real time video processing model in Simulink. As the model is running in Simulink, I need to assert and unassert the DTR pin of the COM port several times. Right now I have to open the port each time I want to change to the pin's status, and then close it (I call a Matlab function from Simulink that does s=serial('com1'); fopen(s); s.dataterminalready='off'; fclose(s); delete(s); clear s). This is causing me several problems including undesired voltage jumps upon every fopen and fclose. Is there a way that I can assert/unassert the pins on the COM port from Simulink without being have to open and close the port every time? In other words, may I open the port just once before running my Simulink model and have access to it from Simulink throughout the running of my model? If yes, how can I do this?
Thank you,
Negar
During initialization open the serial connection and store the serial object in the persistent variable, then during termination close the connection.
This way you only open/close once per simulation.
Phil.