VB6 and the propeller
Rick_H
Posts: 116
I have a nice tutorial for using VB.net but I am really starting to hat .net, mostly due to the fact that you can't simply create object arrays. Is their a tutorial on using MSComm for the prop about? I haven't been able to find one yet.
Comments
Simple code to send out some data on the serial port
Then you need to collect data coming back the other way. Have you got serial working on the propeller yet?
Here's a basic C# serial port terminal.
http://www.agaverobotics.com/serialportdemo.zip
If you can show me no more than 2 lines of code to add 256 text boxes to a list I will live VB.Net, I'm just not convinced.
List <TextBox>
Thanks localroger, I haven't had an issue yet with MSComm yet but I am certainly gonna try your modal out. What issues have you had with MSComm?
hear is the form code, it requires a combobox named cboComm
when I do the above I get "Cant open port 4" so I am not sure what I am doing wrong.
After I added the "com" & cboComm.Text to the port it just crashes VB.
Just for educational purposes, this is how to open a serial port in .NET
The Win API is great and I'm sure localroger has it wired up nicely. I did the same thing years ago for the same reason. I remember it took a little research to understand how the Win API worked.
it tells me that a declaration is required.
Error 1 'TextBox' is a type and cannot be used as an expression.
Error 2 Identifier expected.
Error 3 'For' must end with a matching 'Next'.
Error 4 Overload resolution failed because no accessible 'Int' accepts this number of arguments.
Error 5 ')' expected.
Error 6 Syntax error.
Error 7 'tbArray' is not declared. It may be inaccessible due to its protection level.
Error 8 'i' is not declared. It may be inaccessible due to its protection level.
Error 9 Method arguments must be enclosed in parentheses.
Error 10 Character is not valid.
Error 11 'tbArray' is not declared. It may be inaccessible due to its protection level.
Error 12 'i' is not declared. It may be inaccessible due to its protection level.
Error 13 Method arguments must be enclosed in parentheses.
Error 14 'i' is not declared. It may be inaccessible due to its protection level.
Error 15 Character is not valid.
Error 16 'tbArray' is not declared. It may be inaccessible due to its protection level.
Error 17 'i' is not declared. It may be inaccessible due to its protection level.
Error 18 Method arguments must be enclosed in parentheses.
Error 19 'i' is not declared. It may be inaccessible due to its protection level.
Error 20 Character is not valid.
Error 21 'tbArray' is not declared. It may be inaccessible due to its protection level.
Error 22 'i' is not declared. It may be inaccessible due to its protection level.
Error 23 Method arguments must be enclosed in parentheses.
Error 24 Character is not valid.
Error 25 'tbArray' is not declared. It may be inaccessible due to its protection level.
Error 26 'i' is not declared. It may be inaccessible due to its protection level.
Error 27 Method arguments must be enclosed in parentheses.
Error 28 'i' is not declared. It may be inaccessible due to its protection level.
Error 29 Character is not valid.
Error 30 'this' is not declared. It may be inaccessible due to its protection level.
Error 31 'tbArray' is not declared. It may be inaccessible due to its protection level.
Error 32 Comma, ')', or a valid expression continuation expected.
Error 33 Syntax error.
Here's the code behind of a windows form for named form1. The textbox arrays are initialized and rendered in the form constructor. I changed the arrays to 25 items.
VB.NET version.
If for some reason you decided to use .NET, learn C#. It pays better.
Some problems I've had with MSComm include returning a null string for a result after I've established that characters are waiting, and failing to call OnComm events reliably. These might be API issues. But the biggest nuisance is that MSComm must be registered by an installer, and it can be registered for runtime use only. What spurred me to write serapi was being at a customer site where he had his own copy of VB on the computer. I realized I needed to do some debugging, and when I went to run it in the development system it failed because he had the standard edition of VB which doesn't come with MSComm. The compiled app would run because I'd run the installer, but it had registered MSComm for runtime use only and I couldn't load it into the IDE.
By eliminating that final dependency, my VB6 executables now run without being installed on any Windows 2000, XP, or 7 box, and on any NT box which has ever had a VB6 app installed (so that the VB6 runtime is registered). This means I can tell my customers to back up their installation by just copying the folder with the executable and all their data; if they drop that folder onto another machine it will run.
In Python, I know it's using Myro to convert a command such as beep(3,1000) to a format that the FLUKE understands. I've been using this page as a reference: http://wiki.roboteducation.org/Scribbler_Wire_Protocol
It shows the commands and what they should do, but i'm not getting any response from Scribbler.
Maybe i'm not converting to hex correctly? I've been trying like this:
MSComm1.Output = Hex$(Me.txt_chr.text) Where txt_chr.text is one of the numeric values from the page above. (IE 33)
They talk on that page about the data having to be "a constant 9 bytes long." I'm not quite sure how to set it up like that.
For example, they give this as a example string
name values notes SOFT_RESET 33 Format: 33 0 0 0 0 0 0 0 0, Notes: Performs a software reset of robot. (turns name broadcast back on)
But I don't know what to send to the comm port.
Further down in that document, using the debug in Python, you can see that a simple forward command is represented like this:
>>> forward(1, 1) _write: m