DraftDocSerialComm
From Open Circuits
[edit] Running
Fill in one of the blanks under Data ( the column by defaults contains SendMe ) and press the <Send> button. The device response ( if any ) will appear in the corresponding Received Data field. You can edit the data and send it again or just send it again. The panel on the bottom shows the activity of the application >> precedes sent data, and << received data. The rows are repeated so that you can easily switch between string sent.
One somewhat complicated, but important area to understand is how the program knows that the microcontroller has finished responding. We have three ways:
- Wait for some special character ( which I call the termination character ) to be recieved. Very often the carriage return serves this purpose. In this program you can specify a character for the program to look for.
- Wait some maximum anount of time and assume by then that the microcontroller is finished. This method is not fast, and is not particurllarly reliable. Nice to have as a backup method or if waiting for a termination character when the microcontroller has crashed could wait forever.
- Stop after some maximum length of response. Alsmost always an error condition.
These are specified by entering data in some of the gui fields and can be different for different data that you send.
The initial values in the GUI give you some idea ( I hope ) on how to use them. Here are some details on all the Graphical User Elements.
| GUI Element | Use |
|---|---|
| Button: Send | Press it to send your data. ( the data in the field to its right ) |
| Field: Title Bar of Application | Output: Displays application name, version ( often a date ) and the name of the property file being used. |
| Field: Data | Input: The data you want to send. This field uses special character translation so you can send any ASCII character(s). See Special Character Translation below. |
| Field: Waits | Input: A time in some arbitrary units that the probe will wait for a return from the BitWacker. Data usually comes back pretty fast. Try starting with 50. If the termination reason is maximum wait exceeded, the time has run out and you may have an error condition or need to increase the time. |
| Field: Term C: Termination Character | Input: A string for the character you want to be used by the microcontroller to indicate that its transmission is over. This field uses special character translation. The most common termination is the carriage return “~r” |
| Field: Maximum Length | Input: The maximum length in character of the response that will be accepted from the BitWacker. If it is exceeded the response is cut off and the termination reason is listed as maximum length exceeded. |
| Field: Response | Output: Whatever the microcontrolller returns for data. Cut off at the first occurrence of the termination character if any. |
| Field: Termination Reason | Output: The reason why the received data was terminated. Normally it is an error if the reason is anything other than Termination Character received. |
| Field: Log Area |
Output: Lots of information about events in the probe are logged here ( and to the log file ) This is normally set up information and then when data is sent it is preceded by >> and when it is received it is preceded by <<. You cannot type in here, but can highlight text and copy it. |
| Field: Comment |
If you enter a comment here you can log it to the log area by pressing the <Log Comment> button. This data is just for the log and is not sent to the microcontrolller. |
| Button: Comment | Send the data in the comment field to the log area, none of this is sent to the microcontroller. |
| Field: Term Char for All Sends | This data is appended to the end of all data sent, leave it blank if you do not want to use it. |
| Menu: File -> Clear Log | Clears the log area ( no effect on the log file ). |
| Menu: File -> Clear Pending Data | Checks the recieve buffer for data from the bitwacker that came in after the end of the last recieve. Log it, but otherwise throw it away.
Sets up for clean communication on the next send, but lets you see that there was some unprocessed data. |
| Menu: File -> Open Property File | New -- think it works Opens a dialog for you to choose a new property file ( or the same one, but with edited values { or not if you just want to reinitilize ] ) and reinitilize the application with different ( or the same ) parameters. If you want you can open the property file in an editor, edit values, save ther file ( and possibly keep it open, or not ) and then reload the same file with the new parameters. |
| Menu: File -> Open Comm Parms | Stubb -- does not work, may not ever work. Lets you choose communications parameters on the fly without messing with the property file. |
| xxxxx | Playback the log file by reissuing the earlier commandds that were sent, ignore the rest. |
| Menu: File -> Clear Log | Clear the log area of the screen, but not the log file. |
| Menu: File -> Close Connection | Closes any open connection. |
| Menu: File -> Reopen Connection | Closes any open connection and uses the current parameters to reopen the connection, may be useful if you tried to connect to a device that was not powered up, or failed in some way. |
| Menu: File -> About the Application | Display information about the application. |
| Menu: File -> xxx | |
| Button: Reset -> xx | Reset the BitWacker. No inputs or outputs. |
| Button: Version | Gets the version information from the BitWacker. Output to the Version field. |
| Menu: File -> xx | |
| Menu: File -> xx |
Each time the application initializes it either starts with an empty log file or appends to the old one, I need to find out which, what would you like it to do? Append seems the right choice to me.
Logging on start up:
Typically something like ( this is using the opening using a "PROBE" for the comm port in the property file):
- Reading property file C:\Russ\Java\RS232Etc\MrMoose.properties
- Stream File = C:\Russ\Java\RS232Etc\MrMoose.properties
- COM3 Opened Now Probing Response UBW FW D Version
- <<v
- COM6 Opened Now Probing Response UBW FW D Version
- <<
- COM7 Opened Now Probing Response UBW FW D Version
- <<
- COM10 Opened Now Probing Response UBW FW D Version
- <<
- COM12 Opened Now Probing Response UBW FW D Version
- <<
- COM13 Opened Now Probing Response UBW FW D Version
- <<
- Parms.initPort() failed
- RS232 Probe initilization complete.
Data transmitted to the microcontroller is preceeded with >>, data recieved is preceeded with << ( no data recieved in the above example ).
There is also a bunch of logging to the java console, some of it is the same as to the log area and file, other logging may be different, particurlarlly for execptions that the application does not do a good job of managing. Take a look at this if the application seems to behaving oddly. There is more information on the scanning of com ports, something like:
- Reading property file C:\Russ\Java\RS232Etc\MrMoose.properties
- openOutputStream for rs232probe2.txt
- Looking for port: COM15
- Found port: COM3
- Found port: COM6
- Found port: COM7
- Found port: COM10
- Found port: COM12
- Found port: COM13
- Found port: LPT1
- Found port: LPT2
- Port not found: COM15
- Parms.initPort() failed
In this case it is scanning for port 15, but it is not active so initialization fails.

