<p>I have an xPC target application that talks to a device over RS-232. I am using the xPC serial block for this.<br>
To talk to this device I first have to start at a default speed, say, 9600 bps, request a change of speed to, say 57600 bps, then change the speed on my side to match it.<br>
The problem with the xPC block is that it forces you to choose a specific speed before running, and can't change it at run time. Is there a way/trick/hack to do this?</p>

[{'answer_id': 43213, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': "<p>Here is my take so far. I don't think it can be done using existing Simulink blocks. I think I am going to have to take the xpcserial C code that comes with Matlab, take the code that sets the RS-232 speed, and wrap it in my own S-function.</p>\n"}, {'answer_id': 43244, 'author': 'Will Robertson', 'author_id': 4161, 'author_profile': 'https://Stackoverflow.com/users/4161', 'pm_score': 1, 'selected': False, 'text': "<p><strike>I agree with you: I don't think it can be done, I'm afraid.</strike></p>\n\n<p>On further reflection, I've realised that in my xPC system, I get a compilation warning telling me that the <em>blocks I'm using</em> don't support sample time changes during runtime; this implies that it's not impossible in general…</p>\n"}, {'answer_id': 241048, 'author': 'XPav', 'author_id': 27550, 'author_profile': 'https://Stackoverflow.com/users/27550', 'pm_score': 0, 'selected': False, 'text': "<p>Ian,</p>\n\n<p>What I've done before on this stuff is just modify the registers behind XPC target's back.  It's ugly, but xPCTarget is ugly in the first place.  </p>\n\n<p>Try modify Line Control Register and set the divisors directly -- all you need is the serial port IO address, and you know that.</p>\n\n<p>It's worth a shot anyway, you're going to have to do it anyway.</p>\n"}]
['https://Stackoverflow.com/questions/43211', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']