views:

65

answers:

1

I have a program that reads data from a scanner via the serial port. This program works fine on Windows XP. We have a terminal server set up running Windows Server 2008. I run HyperTerminal on our test terminal, it connects and reads the scanner data fine through COM1. I run my app on that same test terminal and get nothing when I scan.

My app connects to COM1 without errors and disconnects without errors. BUT, the DataRecieved event is NEVER getting fired. Neither is the ErrorReceived event. I have played with the Handshaking, with the RecievedBytesThreshhold and pretty much every setup setting I found. Set it up exactly like the settings on Hyperterminal. I have even tried starting a timer on a different thread to call ReadByte every second to try to KICK this thing into doing SOMETHING. Nothing has worked.

I have been trying to fix this for an entire day now. Added events to my class trying to see EVERYTHING that is going on. All I know is, it connects to the port and it disconnects from the port correctly but nothing happens in between. No data when I scan. No event fired at all between connecting to and disconnecting from the port. I'm tired of google. :-)

HELP!! Please???

PS I have also downloaded other's simple serial communications applications. Nothing in .NET works. Period. :-(

Port SetUp code (mvarSerialPort is COM1):

If ComPort Is Nothing Then  
    ComPort = New SerialPort(mvarSerialPort)  
    ComPort.BaudRate = 9600  
    ComPort.Parity = Parity.None  
    ComPort.StopBits = StopBits.One  
    ComPort.DataBits = 8  
    ComPort.ReadTimeout = 2000  
    ComPort.Encoding = System.Text.Encoding.ASCII  
    ComPort.Handshake = Handshake.None  
    ComPort.ReceivedBytesThreshold = 1  
End If  
If Not ComPort.IsOpen Then ComPort.Open()  
ComPort.DtrEnable = True  

DataReceived event (which is never fired on that darn terminal):

Private Sub Scan(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)     Handles ComPort.DataReceived  
    Dim sDataStatus As String = ""  
    Select Case e.EventType  
        Case SerialData.Chars  
            sDataStatus = "Data Received Event - Chars "  
        Case SerialData.Eof  
            sDataStatus = "Data Received Event - Eof"  
    End Select  

    RaiseEvent ClassStatus(sDataStatus)   

    Dim delInvoke As ScanResults
    delInvoke = New ScanResults(AddressOf RaiseScanEvent)
    delInvoke.Invoke()

End Sub  

RaiseScanEvent (This works great on my computer and my coworker's computer running XP)

Private Sub RaiseScanEvent()  
    Dim sScanned As String = ComPort.ReadLine.TrimEnd  
    RaiseEvent ClassStatus("RaiseScanEvent data: " & sScanned)  
    RaiseEvent ComDataReceived(sScanned)  
End Sub
A: 

Not really a definitive answer I'm afraid, but a few things to try/consider:

  • Does mvarSerialPort really have the value of "COM1" on the terminal?

  • Possibly try setting DtrEnable = True before opening the port.

  • Using a port monitor, such as PortMon is a good idea, although it does give you pretty low level info. You may be able to compare results of working PC's with the terminal machine. At least it may show you any activity when the scanner does its thing.

  • If you have another COM port on the terminal machine (increasingly unlikely these days though, but you could use a USB-Serial converter just for testing purposes) you could try making/buying a null-modem cable. Then you can connect both theses ports together. This way, you can have your app connected to COM1 and Hyperterminal to COM2 (or whatever). This will effectively allow you to type to your app with Hyperterminal.

Andy
Yes, mvarSerialPort is really COM1. :-) That was the first thing I checked. I did try setting DtrEnable before and after (along with several other settings lol) Looks like this is an issue with the terminal software. The .NET apps work on CE4 but not on CE5. The system guys have a call in to the manufacturer to figure out what's up. I'll keep this question updated in case anyone else runs into this issue.
Pamela Hays
@Pamela : OK, will be interesting to see what they come up with. Good luck!
Andy
The manufacturer has to fix the problem. We had to downgrade the terminal software to the previous version until they fix the new version.
Pamela Hays