¡@
1. What should the program Do ?
As a programmer, we should write down the main function of this program.
Variable Transmission Rate
Although our Tx / Rx is set to 2400kbps, the program should be able to perform higher speed testing if we improve our Tx / Rx module
in the future.
Duplex Chat mode
Chat mode is short word string transmission. It is the fast way to check whether the connection is setup. Duplex mode is necessary because
we will need duplex channel testing in the future.
Duplex Error Test mode
Relative to Chat mode, Error test mode is to send date in variable length . It can be used to simulate a file transmission.
Error rate calculation
Once it received the testing message, the program should be able to compare it with correct message table and calculate the error rate.
Compatible to (Ms) Windows
Sadly, more than 80% of computers use MS windows as their primary OS......
¡@
2. Use Com Port in Visual Basic
Visual Basic is quite a easy program to learn. It takes me 3 days to read 400 pages of manual before starting working on the main program.
¡@
General Properties
Mscomm1 is a function in VB to control Com port. It has the following properties.
Properties |
Description |
CommPort |
Sets and returns the communications port number. |
Settings |
Sets and returns the baud rate, parity, data bits, and stop bits as a string. |
PortOpen |
Sets and returns the state of a communications port. Also opens and closes a port. |
Input |
Returns and removes characters from the receive buffer. |
Output |
Writes a string of characters to the transmit buffer. |
For example, if we want to use comt 1 with 2400, non parity , 8 data bits, stop bit =1
MSComm1.CommPort = 1
MScomm1.settings = 2400,n,8,1
Mscomm1.portOpen = True
Note that portOpen must after the "settings" and "comport" property.
¡@
¡@
How to Transmit and Receive
To Transmit data or Receive data, we should put strings in Input or Output buffer.
Example:
MSComm1.Output = strOutput
strInput = MSComm1.Input
We can use a do-loop to monitor the input buffer all the time.
Example:
Do Until
cancelflag = True
If MSComm1.InBufferCount <> 0 Then ' print only when there receive
something
text_rx.Text = text_rx.Text & MSComm1.Input 'show Rx data
text_brx.Text = text_rx.Text
End If
DoEvents
Loop
Here we print the received data in to test_rx.Text and attached new messages on when they are received.
¡@
¡@
3. Intro. to Talk Mode and Error Test Mode
Talk mode
Talk mode is the extension of the loop above. If there is "DoEvents" in the loop, then we can halt the loop if user triggers another
action; that is , click the SEND key. The loop continues after finishing the action.
¡@
Error Test Mode
In Error Test mode, we must setup a "Table" that should be the same in each test parts.
Tx will transmit the content of the table to Rx. Rx will compare the received date with the "Table" and calculate the error rate.
¡@
When the "Calculate" command is clicked. It will store both Table and Received words into array, and compare each unit of the array.
Users can types any thing they want to transfer in Table area, but must make sure that both test part share the same table.
¡@
4. Miscellaneous Notes.
To state full program line by line is impossible. Here are some key notes that will be very useful to users and those who want to modify
the program.
Error test Page
1. If there are pages of data in "Received words", It might take much memory to store the array. The most top text area will
show what's in the array.
2. It always compare the data from the top of "Received Word" text area. As a result, one should click "Rx clear" before
performing error test unless he wants to calculate the total received words.
3. When "Test command" is clicked, "Transmitted Word" area will show what is transmitted. Old message won't be erased
unless "Tx Clear" is clicked. It will be useful in counting how many words has been send.
¡@
Setup Page
1."Flow control" and "Echo " is reserved for future use. It might need CTS and RTS signal of RS232.
2. Each time user changes the setting, he must go to Main page to disconnect and re-connect again.
3. Transmitting over 1000 words in "Error test" with slow speed ( 300 bps) will suffer some words lost,
even in perfect channel ( connect Tx and Rx in Com port with short wire). I "guess" the reason might be that we halt
the loop in order to perform transmission, but the loop continues before it finish sending out all the data in buffer.
¡@
Main Page
1. Always Use "Exit" to end the program or there will be error message such as "Port is still open"
2. Tx/ Rx selection will only for "stupid protection" . It shut down Tx function if receiver is selected, and shut down Rx function
when Tx is selected.
OCX missing
If windows complains missing Tabctl32.OCX , just copy TABCTL32.OCX or MSCOMM32.OCX into windows\system32.
¡@
5. 1 PC , 2 PC Test
1 PC Test
Use 1 PC to test the program is the most convenient way. We just have to connect Tx and Rx together in Com port.
¡@
2 PCs test
Performing 2 PCs test, we could connect Tx of PC 1 to Rx of PC2 and vias versus. Remember to Connect Signal Ground to each other, or they won't talk to each other.
Result
Our 1 PC test is successful immediately, but the success of 2 PCs takes 3 hours because we forget to connect signal ground
together !
¡@