![]() |
Remotely changing baud rates.
What is the correct way to remotely change the baud rate of an external device? For example I have an LCD module that can be set to multiple baud rates. It defaults to 9600. I have a software application that allows the user to change the baud rate via serial obviously. I am having trouble reconnecting to the LCD module after this change is made. Here is my logic.
Connect to the LCD module via serial at 9600 bits/second using .Net's SerialPort class. Send the correct byte to inform the LCD module to change its baud rate to 57600. Close the connection between the LCD module and the host computer. Open a new connection between the LCD module and the host computer using a baud rate of 57600. To me this makes sense, however this logic doesn't seem to work. I can not communicate with the device after this. |
Re: Remotely changing baud rates.
One would need the docs for the LCD module to say much, but are you getting all the other parts right (stop bits, parity, handshaking, etc.)?
|
Re: Remotely changing baud rates.
I have all of the other parts right. Does this logic sound correct to you? If so, I am more than likely missing something in my code.
|
Re: Remotely changing baud rates.
It just seems strange to me that you can change the baud rate of the LCD device with a single byte. There are, after only, only 256 of those available. What if it occurs in your normal data stream? I would have thought there would be some sort of AT sequence or escape sequence.
|
Re: Remotely changing baud rates.
The LCD requires two bytes to change the baud rate. The first byte is a byte that indicates that we want to change the baud rate and the second byte is a specific byte that maps to a specific baud rate, which are defined in the LCD documentation. However, I found my problem. This line is taken from the MSDN documentation on the serialport.Close method.
Quote:
Now you would think that you could poll the IsOpen property until the port was closed, however you can't because it is set to false as soon as the Close method is called. I guess the question now is how long does it take to close a serial port? Suspending the thread for 1 second, does not work. Suspending for 5 and 2 seconds does work. I'm assuming the time is variable, so it may be best to stick with 5 or maybe 3 seconds. |
Re: Remotely changing baud rates.
Let me repeat: you have not previously given us all the information required, which you have subsequently discovered. In the absence of critical information, you have limited us in the applicability of the responses that we might undertake.
Bad boy. You might want to review the FAQ and the "How to Post" entries that tell you that information is the key. It''s just a suggestion, of course, you are perfectly free to disregard such supposedly important stuff. |
Re: Remotely changing baud rates.
I will disregard your last comment. I have given you the information that you asked for in the first line of my previous post. Maybe you did not read my post in its entirety, but I said my logic works if I suspend the thread for two seconds. So what does your last comment have to do with escape sequences? At any rate, the close time will depend on how much data is left in the data output buffer and a second or two to fully close the serial port.
The LCD module expects TWO bytes to change the baud rate. There is no AT or escape sequence. It uses control characters. Quote:
|
Re: Remotely changing baud rates.
You may disregard any comments you care too; certainly if you live in the same country I live in. You may also kiss my butt and solve your own problem, if that is your desire.
|
Re: Remotely changing baud rates.
I would rather solve my own problem than have to listen to a grouch like yourself. Go back to bed.
|
Re: Remotely changing baud rates.
No, thanks. I'd rather stay up and watch you putter around like the amateur stumbler you are.
|
| All times are GMT -5. The time now is 3:29 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC