Author Topic: communicating with serial ports from XP  (Read 1968 times)

trendyironicname

communicating with serial ports from XP
« on: November 29, 2007, 03:32:19 AM »
I would really like to figure out how to communicate straight to a serial port.  Maybe a library in c++.  I have .net and I'll be willing to try and figure out another language or relearn some vb if it would make it easier.  My old teacher set up a REALLY simple vb program to play with a lightbox that I have.  It was on a much older machine and os but I would like to get back to a program like that to flesh out.  I'm still green enough that I sort of need a jump start sometimes when I get stalled out.  Any help is MUCH appreciated.     
There are 10 types of people in the world, those who understand binary, and those who don't.

anchovie

Re: communicating with serial ports from XP
« Reply #1 on: November 29, 2007, 08:05:25 AM »
This is some code that I wrote in VB.NET 2005. You need to import the System.IO.Ports namespace.

Code: [Select]
Private Sub TextToSerial(ByVal text As String, Optional ByVal port As Byte = 1, Optional ByVal baud As Integer = 111520)

        Dim com As SerialPort
        com = New SerialPort
        With com
            'Configure serial port
            .PortName = "COM" & port
            .BaudRate = baud
            .Parity = Parity.None
            .DataBits = 8
            .StopBits = StopBits.One
            .Handshake = Handshake.None
            .ReadTimeout = 500
            .WriteTimeout = 500
            'Attempt to write text to serial port
            Try
                .Open()
                .Write(text & vbCrLf)
            Catch ex As Exception
                MsgBox("Unable to write to serial port " & .PortName, MsgBoxStyle.Critical)
            Finally
                If .IsOpen Then .Close()
            End Try
        End With

End Sub
Bringing you yesterday's technology tomorrow.

David

Re: communicating with serial ports from XP
« Reply #2 on: November 29, 2007, 09:10:52 AM »
Ummm...  how about HyperTerminal?

trendyironicname

Re: communicating with serial ports from XP
« Reply #3 on: November 30, 2007, 12:07:15 PM »
Thank ya'll.   I was looking at more pin manipulation.  I have an 8051 board thing I built for a project that I use with hyperterminal but it doesn't really help with what I want to do with the light box.  The 8051 is giving me fits itself.  I have no idea what bootloader monitor program is on it and once I started trying it with my laptop (the desktop is long gone) it would communicate with hyperterm still but it wouldn't be able to find the files i wanted to program onto it.  I tried everything short of buying another desktop.  It just stalls out I suppose looking for an a: drive that no longer exists.  Tried tricking it too many ways to no avail.
There are 10 types of people in the world, those who understand binary, and those who don't.