Author Topic: Serial Port Latching?  (Read 19765 times)

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Serial Port Latching?
« on: December 06, 2012, 05:47:37 am »
Hi All,

I have been tasked with replacing a legacy piece of kit a PSION Walkabout (old version) with a serial port program to emmulate it.  I have noticed there is an issue with sending the commands and getting the responce back, it appears that the device latches the data on the port meaning the data is read into my program but is still there on the next action I have tried to use the below to clear and reset the port.   
            myComPort.DiscardInBuffer();
            myComPort.DiscardOutBuffer();
            rtbIncomingData.Text = "";
This appears to kill all comms back from the unit, also some times it would appear that I have to send the command multiple time for a responce.  The problem is I need a way of my code over coming this as there is not really a method of getting around this problem by altering the firm ware. Just thinking (even Jans example code has issues)

Sorry getting pulled for something else!

Glenn

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Port Latching?
« Reply #1 on: December 06, 2012, 01:01:55 pm »
If the PC is sending the command multiple times, it's possible the device is responding multiple times.

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Serial Port Latching?
« Reply #2 on: December 07, 2012, 05:30:42 am »
I'm not sending it more than once.  It appears as if the data remains there (latcing if you will) until it is cleared as this is a bit legacy hardware the documentation is none existant from what I can see (also the orignal coder has been lost to time so there is no chance of asking them).  I am using a method that uses ReadExisting() where as this method has used ReadLine() but I don't think the reply gives a new line as I don't get anything reply wise from the unit.  However a monitor program show 0a 0d which should be Cr Lf, I'm confused.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Port Latching?
« Reply #3 on: December 07, 2012, 10:29:18 am »
Regardless of whether the data is latched at the device, the receiving PC will read incoming data only once. To read it twice, the device needs to send it twice.

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Serial Port Latching?
« Reply #4 on: December 11, 2012, 07:31:08 am »
That would make sense, a request for data is sent, the reply got, next command sent, the reply is for the previous command, however if HyperTerm is used the problem is not present.  I am trying replicate the Hyper Terminal with a series of button clicks.  I was wondering if it was something to do with the way I was writing the data out of the port I am using  a .Write with a char (10), char (13) to act as a cr lf, if a WriteLine() is used the command is ignorred (?).  I have also tried your Com port program (I always tend to double check with your code when I have an issue) and found that your example code will talk out (the characters are echoed in green) but it can't see the reply.  I am thinking it is due to fact that is a single wire interface to the PIC (ie 1 track  covering RX & TX on the PCB, classic!). I am still a little stumped as to why WriteLine() does work the same way as Write()+char(10)+char(13) ?
Glenn     

towlerg

  • Member
  • ***
  • Posts: 24
Re: Serial Port Latching?
« Reply #5 on: December 11, 2012, 09:13:21 am »
Hi

what kind of handshaking (if any) is being used?

George

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Port Latching?
« Reply #6 on: December 11, 2012, 10:33:57 am »
What is the circuit that converts the 1-wire interface to 2 wires?

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Serial Port Latching?
« Reply #7 on: December 11, 2012, 11:40:06 am »
This is the problem, it's an acient NEC part in the process of being replaced by a PIC (not on the board I am using, I typed PIC as that is what I am used to!), due to several reasons one of which is no-one knows how or why it works or has the diagram.  I have reversed engineered what I have.

Glenn

Also to George, the handshaking is set to none, this was gleaned from the PSION Code. Does anyone know a Forum for PSION users all the ones I have found are dead the latest update being 2003!
« Last Edit: December 11, 2012, 12:19:27 pm by GlennP »