Results 1 to 16 of 16

Thread: .net Serial Port

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Resolved .net Serial Port

    I for years I have used MSCOMM32.OCX to handle serial port comm in vb6. Is this the "proper" way to handle the serial port in .net or is there another better way?
    thanks
    kevin
    Last edited by kebo; Jan 31st, 2005 at 11:35 AM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Check out this thread . I posted a link to the .NET way of doing so :
    http://www.vbforums.com/showthread.p...hreadid=305829

  3. #3

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: .net Serial Port

    thanks Pirate, but I must say that it appears that using the comm port just got a bit more difficult. I have a few questions---
    VB Code:
    1. m_CommPort.Open(m_ModemPort, 115200, 8, Rs232.DataParity.Parity_None, Rs232.DataStopBit.StopBit_1, 4096)
    this is how you open the comm port. Can I define the behavior of the port during an init segment of code and omit the arguements?
    VB Code:
    1. m_CommPort.Write(Encoding.ASCII.GetBytes(Me.txtUserCommand.Text & Chr(13)))
    Do I alway need to specify the encoding? or can I set it to default ASCII?
    VB Code:
    1. m_CommPort.Write(Encoding.ASCII.GetBytes("AT" & Chr(13)))
    2.             ' Sleep long enough for the modem to respond and the timer to fire.
    3.             System.Threading.Thread.Sleep(200) '<===
    4.             Application.DoEvents()
    5.             m_CommPort.Close()
    what is the purpose of the Thread.Sleep statement?

    finally--- Is it really that bad to stick with MSCOMM32.OCX?
    thanks
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Sorry dude,I've never done something like this before . Just tried to help even with a link .

  5. #5

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: .net Serial Port

    its cool, thanks.....anyone else?
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  6. #6

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: .net Serial Port

    Sunday Morning bump.......
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  7. #7

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: .net Serial Port

    Monday morning bump....
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  8. #8
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: .net Serial Port

    Hi
    Each form as a thread responsible for updating your form GUI, using System.Threading.Thread.Sleep(200) will make that thread sleep for 200ms and you will notice that the GUI stops responding during that time.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  9. #9

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: .net Serial Port

    thanks Jorge,

    that takes care of one question, but I think the rest of them are irrelevant if the last can be answered with a no----Is it so bad using VB6 ocx's such as MSCOMM32.ocx in .net? What are the implications of using VB6 control in .net?
    thanks
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  10. #10
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: .net Serial Port

    Hi
    When you add a vb6 control to your .net project it will create a wrapper dll starting with interop.yourcontrolname.dll on your \bin directory, so there disk space wasted and performance hit, Interop is very slow compared to .net .


    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  11. #11

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Resolved Re: .net Serial Port

    thanks....I guess I learn the .net way of doing it.
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ok that's much better . But I just want to add my 2cents . Using interop VB6 with .NET isn't like so bad but it's always not recommended .Simply because the overhead it causes , delay of execution , not 100% handled by the CLR environment and most of all , the data types are quite different .For example , Long in VB6 is Integer in .NET , Any or Variant is Object in .NET .

  13. #13
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: .net Serial Port

    There was a thread I found that I think was started by Wossname about serial ports in .NET. A links were provided to at least three places that had free downloads of .NET serial port wrapper classes. I studied two of them, and ended up using one of them in my own project (with modifications)

    Unfortunately, I haven't been able to find those links again. However, I do have the downloads lying around here somewhere if you'd like them.
    My usual boring signature: Nothing

  14. #14

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: .net Serial Port

    Quote Originally Posted by Shaggy Hiker
    There was a thread I found that I think was started by Wossname about serial ports in .NET. A links were provided to at least three places that had free downloads of .NET serial port wrapper classes. I studied two of them, and ended up using one of them in my own project (with modifications)

    Unfortunately, I haven't been able to find those links again. However, I do have the downloads lying around here somewhere if you'd like them.
    Yes please send them
    thanks
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  15. #15
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: .net Serial Port

    Here are 3 files (I hope, I've never actually attached a file to one of these posts before). The two zip files are the free downloads from places probably included in text files in the zips. They are small projects that test a core RS232 wrapper class (a different class in each project, not the same class).

    I forget which one I included in the RS232.vb file, and I forget whether or not I made any modifications to the file, but the one I chose was simple to use, and could readily be plugged into my application.
    Attached Files Attached Files
    My usual boring signature: Nothing

  16. #16

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: .net Serial Port

    thanks
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width