Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello everyone,

I'm attempting to do serial communication from within a c++ program.
"When it's done" it will deal with communication PC <-> mController.

I found the CSerial library which I think I will use, see here:
Serial library for C++[^]

To test that receiving data works I want to use a "GPS Simulator" from here:
http://www.skylab-mobilesystems.com/en/products/gps_sim.html[^]

However, as soon as I start outputting the GPS NMEA sentences from within the GPS simulator the COM-ports status goes to "busy".

If I then attempt to open a port from within my C++ code this doesn't work anymore.
CSerial serialPort;
serialPort.Open(_T("COM1"));


Has anyone attempted something similar?
Do I need to handle this differnly from the C++ side?
Or did I misunderstand the purpose of the "GPS Simulator"?
Could be it outputs the signal to the COM port where it could be read by external devices connected to the port ... not completely sure.

If my attempt is something not easily doable, what are alternatives which allow me to test communication without actually having connected the device which will be "on the other end"?
Posted

it looks like that product outputs the NMEA over the com port so another external device can consume it - not really what you're after

Either connect another computer with a null modem cable (or a computer to itself if it has 2 com ports) or use a virtual serial driver that understands how to loopback - something like http://www.eltima.com/products/vspdxp/[^] may help you achieve what you want ... not endorsing it, first thing i found when i googled
 
Share this answer
 
Comments
tschoni 20-May-11 23:32pm    
thanks for the good suggestion
this looks exactly like what i need, will test it this afternoon and post whether it did what i wanted :)
VB
End If
          Dim Str As String = Nothing
          Dim StrArray() As String = Nothing
          With objPort
              If CurrentDataMode = DataMode.Text Then
                  Str = .comPort.ReadLine()
                  StrArray = Split(Str, ":")
                  For i As Integer = 0 To StrArray.Length - 1
                      If i = 0 Then
                          .PortTds = StrArray(i).ToString
                      End If
                      If i = 1 Then
                          .PortHighPh = StrArray(i).ToString
                      End If
                      If i = 2 Then
                          .PortLowPh = StrArray(i).ToString
                      End If
                  Next
              Else
                  Try
                      Dim bytes As Integer = .comPort.BytesToRead
                      Dim buffer(CInt(bytes - 1)) As Byte
                      .comPort.Read(buffer, 0, bytes)
                      Str = ByteArraytohexString(buffer)
                  Catch ex As Exception
                      MsgBox("The Entered values are not in correct format" & vbCrLf & ex.Message)
                  End Try
                  StrArray = Nothing
                  StrArray = Split(Str)
                  For i As Integer = 0 To StrArray.Length - 1
                      If i = 0 Then
                          .PortTds = StrArray(i).ToString
                      End If
                      If i = 1 Then
                          .PortHighPh = StrArray(i).ToString
                      End If
                      If i = 2 Then
                          .PortLowPh = StrArray(i).ToString
                      End If
                  Next
              End If
              Me.txtPortAdd.Text = .PortName
              Me.txtPortStatusRead.Text = .PortStatus
              Me.txtReadHighPh.Text = .PortHighPh
              Me.txtReadPhLow.Text = .PortLowPh
              Me.txtReadTDS.Text = .PortTds
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900