Shop OBEX P1 Docs P2 Docs Learn Events
Need some advice in writing a interface in VB Express for the Propeller. — Parallax Forums

Need some advice in writing a interface in VB Express for the Propeller.

AnubisbotAnubisbot Posts: 112
edited 2007-10-24 18:48 in Propeller 1
Hi,

I have played a lot with my prop now,

And have build a controller card for Light with a prop on.

Now i want to make a litle windows programm, that i want to write in VB Express.

I stardet and played around a bit and got some data transferd over USB-Serial conection , just one byte on the press of a button, but it works.

I want to be able to have a terminal like the Propterminal + a up load of a binary file into the prop epprom.


Does some body have some sample code or know some how tos , what i can read.

Best regards
Anubisbot

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2007-10-21 02:25
    For a simple terminal, you can use a TextBox control from the VB toolbox. Set the multiline property to true.

    Then to display received text you can use the .Text & .AppendText methods for adding to the text box.

    For something more advanced, look into running the textbox updating code on a seperate thread. That way the terminal can receive without locking the main application thread.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-10-21 21:02
    If you are updating a control this requires you to 'Invoke a delegate'

    it is discussed here ...

    http://forums.parallax.com/showthread.php?p=671804

    Regards,
    Quattro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'
  • AribaAriba Posts: 2,685
    edited 2007-10-21 21:55
    Filip S. has made a VB version of the Loader protocol:
    http://forums.parallax.com/showthread.php?p=611536 (on page 3)
    In this Thread you can also find informations about the protocol.

    (BTW: PropTerminal 0.3+ can also upload to eeprom).

    Andy
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-10-23 20:15
    Aribas·link is to a Vb6 application which uses mscomm32.ocx - as opposed to the native .NET (and .NET VBexpress 2005) serialport routines. If the VB6 application was 'converted' using the .NET conversion utility it would create Interop Dll's which would package mscomm controls.Using the·Native .NET SerialPort functions are radically different when it comes to Updating the likes of a textbox·and/or passing the·data·- In that it requires you to 'Invoke' a 'delegate' to do it.

    'Unsoundcode' has broken this down into easy steps - at this link
    http://forums.parallax.com/showthread.php?p=671804


    Regards,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 10/23/2007 8:22:52 PM GMT
  • BeanBean Posts: 8,129
    edited 2007-10-23 23:30
    I have found it just as easy to use a timer to periodically check for serial input and put it in the text box or whatever.

    I haven't gotten around to using delegates yet, but I do like the .NET serial object.

    If you have a Serial Port object named "SerialPort1" and a combobox named "cbSerialPorts", this one line of code will populate the combo box with the list of available com ports.

    cbSerialPorts.Items.AddRange(SerialPort1.GetPortNames())
    

    Cool....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My goal is to live forever...Or die trying.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • AnubisbotAnubisbot Posts: 112
    edited 2007-10-24 13:29
    Hi,
    First, thanks for the help, i am every time impressed, how good the help in this forum is.

    Ok now to my problem, i got the VB to reset my prop, and i learned about timer, since i got nuts to find a delay or wait function...

    To open the port and close it , works like a charm, and since the good idea of Bean the select of the com port works to.

    I still try to figure out how to read a binary prop file to an array and then send it over the serial port.



    I want to post the hole project files later here , so other new commer like me can take it and modify it fast and easy.
    Since i find the VB Express is a good and cheap solution for begiinners.

    But its hard to find some usefull examples to learn off.

    AnubisBot
  • RsadeikaRsadeika Posts: 3,837
    edited 2007-10-24 14:22
    I have been working with C#, some of the programming is similar to VB. In the help file, seraching for 'Read' may give you something to work with. What·I did, for test purposes, to read some bytes,·was use:
    byte[noparse]/noparse Incoming = new byte[noparse][[/noparse]26];
    serialPort1.Read(Incoming, 0, 26);
    This sets up to read 26 bytes that are received over the serial port, now, I do remember that in the help file it did discuss reading files. I did notice that even for C# there·are very few examples in the serial port area. You might also want to try google 'serial com VB express'. Hope this helps.

    Ray
    ·
  • BeanBean Posts: 8,129
    edited 2007-10-24 17:18
    AnubisBot,
    For VB.NET the "stream" object is the easiest to use for file reading and writing.

    bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My goal is to live forever...Or die trying.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-10-24 18:48
    Bean said...
    If you have a Serial Port object named "SerialPort1" and a combobox named "cbSerialPorts", this one line of code will populate the combo box with the list of available com ports.

    cbSerialPorts.Items.AddRange(SerialPort1.GetPortNames())
    

    Thats a nice line of code, previously I always used a snippet to emumerate the ports but will use this one liner in the future thanks.

    Delegates were first pointed out out to me by QuattroRS4 ( I appreciate that John ).· The Data_Recieved event has advantages over using a timer in the fact it is faster and easier to synch. To use the Data_Received event delegates become a neccessity. This link explains·delegates nicely in varying degrees of complexity http://www.developerfusion.co.uk/show/5251/

    Jeff T.
Sign In or Register to comment.