I think the documentation generally needs to be reviewed. It often doesn’t do a good job of explaining how to use various classes and language features. To find out how things work one needs to use this forum, and that shouldn’t be.
Case in point, Serial. I spent a significant amount of time trying to work out the use of Serial.DataTerminalReady. I finally came to the forum and found out how it worked. That is: set Serial.DTR = True, set Serial.DataTerminalReady to True or False, then call Serial.Reset.
In the documentation, under Serial.Reset:
“Changes to the serial device are queued so that you can modify multiple properties of it without them all taking effect immediately. For instance, you can set the baud, parity and stop bits as one operation instead of three. The same thing applies to the line state properties. Once you’ve made all your changes, you need to call .Reset on the serial device to reset the device to the new settings.”
So the information was there. But “the line state properties”? That’s kind of vague. I only read the documentation if I don’t know about the thing already. Once you know, this statement makes sense, what if you don’t?
I am still left wondering which properties exactly are “queued”, given that I have been setting .Baud without calling .Reset, and now wondering how on Earth that ever worked, or if it did.
And Serial.DTR…
Documentation: “Enables DTR (Data Terminal Ready) flow control.”
Not knowing what that meant, it wasn’t immediately clear that this was not controlling the DTR line. Once you know what it means, then it makes sense. If you don’t?
And doesn’t one need to call Serial.Reset to have this take effect? It doesn’t say so. But you can work that out through trial-and-error, right?
You might add, say: “In order to use the DataTerminalReady property, the DTR property must be set to True. If DTR is set to False, then changing DataTerminalReady has no effect.”
And Serial.DataTerminalReady…
Documentation: “Sets the state of the data terminal line.”
That is clear. Except that the author has omitted something: in order to set the state of DTR with this property, you must first set Serial.DTR = True, and then after setting Serial.DataTerminalReady, you must then call Serial.Reset. Now if you didn’t know how to control DTR, and you looked at this documentation, you would not know that you must call Serial.Reset. So what do you do? You spend a significant amount of time f-ing around until you give up and come to this forum to find out how it works.
Now there is something else that was mystifying me, and it would take a scope to figure it out. That is, when you set DataTerminalReady to True, does the line go low or high? I believe it is low as this is the active state right? It doesn’t waste a lot of ink to mention this as well. If someone is using this property, this might be useful information.
WHY NOT JUST WRITE DOCUMENTATION THAT WORKS SO WE DON’T HAVE TO COME TO THE FORUM ALL THE TIME FOR ANSWERS? The documentation in general does not present data in a way appropriate for someone who doesn’t already know.
The company might start by sifting through this forum and finding out what questions are being asked, then go back to docs and see if the explanation can be improved.