Data not saved in device exe

penserv

Member
Licensed User
I've been playing with the Serial2.sbp and for some reason I cannot get the compiled program to change the Global variables. Here is the code...

Sub Globals
port = 1 'changed from 3
bitRate = 3
Dim bitRates(0) As Number
bitRates() = Array(300,4800,9600,19200,115200) 'added 19200 baud rate
End Sub

When this program gets compiled to the device, the highlighted default port is COM 3 and 19200 does not show up in the array. What am I doing wrong?
 

mjcoon

Well-Known Member
Licensed User
When you say
... the highlighted default port is COM 3 and 19200 does not show up in the array.

you are referring to menus or comboboxes in your form? The content of each menu or combobox and the entry that is selected are properties of that item and are not influenced by the code that you showed us. You have to make the two match, perhaps using the form Designer.

Mike.
 

penserv

Member
Licensed User
I'm using SerialTerminal.sbp in the Samples directory. Ports and baud rates are menu items added with AddEvent as follows...

For i = 1 To 8
AddEvent("mnuPort" & i, Click, "mnuPorts_Click")
Next
For i = 0 To 4
AddEvent ("mnuBit" & i, Click, "mnuBits_Click")
Next

From what I can figure out, the values of "i" for "mnuBit" must be hard coded somewhere in the Serial2.dll, but I cannot find any documentation for this specific subject. The problem I have is that my GPS uses a baud rate of 19200, which is not one of the default baud rates that get listed in "mnuBit". It would seem easy to change the baud rate to 9600, but I cannot do that. The value of 19200 is set by the manufacturer. I assumed that the values of "i" were coming from the "bitrates" array in Sub Globals...

bitRates() = Array(300,4800,9600,19200,115200)

but now I think they actually come from Sender...

Sub mnuBits_Click 'Handles mnuBit0-4 click event
Control("mnuBit" & bitRate).Checked = False
Sender.Checked = True
bitRate = StrAt(Sender.Name,6)
End Sub

How do I find out what values Sender is using? I'm running this example on my desktop with no serial ports hooked up and the program automatically selects Com4 and baud rate of 9600, which leads me to suspect that there are hard coded values somewhere (in cyberspace?)...
 

mjcoon

Well-Known Member
Licensed User
.... Ports and baud rates are menu items added with AddEvent as follows...

No, those lines of code merely associate a Sub in the code with the pre-existing menu items, which you can see if you run the "Designer", find "Menu" under the "Controls" heading and look at the different menu items shown there. (See attached screenshot.) Then you should study the features of those menu entries. It may also be a Good Idea to follow some tutorial for using the form designer. (Erel's suggested tutorial was specifically for the AddEvent() operations that you found in the code, but I don't think that you need to know about those. Except that if you add extra menu entries you will need to extend those loops from "0 To 4" to, say, "0 To 5".)

From what I can figure out, the values of "i" for "mnuBit" must be hard coded somewhere in the Serial2.dll, ...

No, they (the bit rates, not "i" which is just a counter) are in both those arrays that you referred to and also in the menu features that I mentioned. You have to keep these lists of numbers aligned.

Mike.
 

Attachments

  • menu.jpg
    23.9 KB · Views: 227

penserv

Member
Licensed User
OK, I found it in the Menu Editor and that's where I can make the changes. I'm still not getting communication with my device, which is a Recon 400 MHz with WM 6.0.2. I've only got COM1 and COM2 as serial ports, so it narrows down my list of things that can go wrong. Once I get the GPS string (GPGGA), then I can get into the really neat stuff, getting the binary string from an EM sensor and appending it to the GGA string at a rate of 5 HZ. Thanks for all you help so far.
 

penserv

Member
Licensed User
Wow, just like magic, it's working now. I just had to get the order of items correct, EnableOnComm, Open Port and Receive and voila - I have a GPGGA string. Now I can get on to the good stuff - binary files.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…