Author Topic: Re: Program to act like HyperTerminal in C#????  (Read 21522 times)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Program to act like HyperTerminal in C#????
« on: June 30, 2010, 05:44:15 pm »
(Moved from General Category)

In the course of Work (mutter, mutter) I have come across an oddity I wrote a C# program to communicate via the serial ports which worked fine until a few weeks ago.  Some of our boards will now not work with my program so have gone back to try to emmulate HyperTerm which will do the job I have managed to get the out put to appear in real time as it is typed with a Rx Tx short (no click send button for text to be sent as a string) but the board sees the data (a flashing LED will indicate that data is being recieved) but the 12 Volt relay is not switched the input routine I am using is :

 private void rtbOutgoing_KeyPress(object sender, KeyPressEventArgs e)
{
   if (e.KeyChar == (char)13) // enter key
    {     
              myComPort.Write("\r\n");
             Thread.Sleep(200);
             tmrPollForRecievedData.Enabled = true;
             rtbOutgoing.Text = "";
    }    else if (e.KeyChar < 32 || e.KeyChar > 126)
    { 
      e.Handled = true; // ignores anything else outside printable ASCII range 
      }    else 
    {   
      myComPort.Write(e.KeyChar.ToString());
   }
  }
This appears to do every thing but the intended to the board I don't want to point fingers and cause my self to look like an idiot if there is a fault at my endbut will this act like Hyper Term?

Glenn

The flashing LED says that data is being received, but you suspect it's not the correct data? Is the relay supposed to open or close every time you send a keypress, or is the firmware reading commands such as "open relay", "close relay", etc.?

I don't know what you mean by this:

I have managed to get the out put to appear in real time as it is typed with a Rx Tx short

In any case, I would suggest using whatever debugging tools you have to find out exactly what the device is receiving. Also check to be sure the port parameters (baud rate, stop and start bits, parity) match.

Jan

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Program to act like HyperTerminal in C#????
« Reply #1 on: July 01, 2010, 08:35:38 am »
Hi Jan,

The Led on the board is supposed to flash when its seeing data, so it sees the data from the Program.  The device uses 38400,8,n,1 if I use HyperTerm set to those specs it talks and acts correctly. If I use my own code for it the Led that flashes while its getting data flashes but nothing comes out.  I am a little at loss why while I dont think its the board(s) a customer has taken delivery and is happy. The command is L000:8:000<cf> if this typed in to Hyper term every thig happens but in my software only the Led flashes meaning it see data I'm wondering if there is a special control charcter (like a line feed) I'm missing does Hyperterm.

Glenn

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Program to act like HyperTerminal in C#????
« Reply #2 on: July 01, 2010, 09:45:22 am »
Hi Jan,
Spotted a typo <cf> when I meant <cr><lf>  the enter key!
Hi Jan,

The Led on the board is supposed to flash when its seeing data, so it sees the data from the Program.  The device uses 38400,8,n,1 if I use HyperTerm set to those specs it talks and acts correctly. If I use my own code for it the Led that flashes while its getting data flashes but nothing comes out.  I am a little at loss why while I dont think its the board(s) a customer has taken delivery and is happy. The command is L000:8:000<cr><lf>  if this typed in to Hyper term every thig happens but in my software only the Led flashes meaning it see data I'm wondering if there is a special control charcter (like a line feed) I'm missing does Hyperterm.

Glenn

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Program to act like HyperTerminal in C#????
« Reply #3 on: July 01, 2010, 09:55:43 am »
You can configure Hyperterminal to add CR to a LF (File > Properties > Settings > ASCII Setup). Perhaps the device expects only a LF, Hyperterminal is sending LF, and your application is sending CR/LF. Just one possibility. You need to know exactly what the device expects and then provide it.

Jan

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Program to act like HyperTerminal in C#????
« Reply #4 on: August 02, 2010, 08:38:41 am »
I think I might have an idea with this, I was sending strings when I should have been sending Bytes. I will try it this afternoon.  I have modded my software so it sends each character as a byte rather than the string it was....

Glenn