UART greeting message or how to check if there is any conn

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

Im using Peter Fleury's UART library, which is kinda simple and gives what i need but still, dont know how i can check if there is any connection in uart.

Ok, so connecting ATmega to usart gives no reset, in this case ATmega runs without stops/resets not like arduino. In the loop, how i can check if there was a new uart connection, since ATmega doesnt resets and i need to print a "welcome message".

Well, i did this in Arduino environment, but i dont like it, its too much space... Anyway sample of arduino code:

if (!Serial) connected = 0;
  if (Serial && connected == 0)
  {
    Serial.println("Welcome to URT!");
    Serial.println("> Type help for command list.");
    Serial.print("> ");
    connected ++;
  }

Oh and, i said about that reset. I need to know real ATmega uptime, so there cant be any resets while connecting to UART. So in this case ATmega does the job here, just need to figure out how to check if some1 connected to UART.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The RS-232 idle holds the lines in the mark state (which at TTL levels is VCC). If the board has a pull-down on the pin, then when nothing is connected to the line, the value on the pin will be 0, and when a UART is connected it will be at logic 1. So the answer is to check the Rx pin value.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Koshchi wrote:
The RS-232 idle holds the lines in the mark state (which at TTL levels is VCC). If the board has a pull-down on the pin, then when nothing is connected to the line, the value on the pin will be 0, and when a UART is connected it will be at logic 1. So the answer is to check the Rx pin value.

Hm, but my USB->UART chip(FT232L) is always connected with ATmega's RX/TX pins, and it powers on together with ATmega.
To connect with pc only usb cable is required. So in this case even if usb isnt connected, rx pin will have a 1 value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Print a greeting at poweron that says "Gizmo program running. q for menu\n" and do a kbhit() in the main loop to see if he whacked a key?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Hm, but my USB->UART chip(FT232L) is always connected with ATmega's RX/TX pins, and it powers on together with ATmega.
To connect with pc only usb cable is required. So in this case even if usb isnt connected, rx pin will have a 1 value.

Then there is no concept of "connected" by only using the Tx/Rx pins. There is no way to discern "not connected" from "connected but quiet". If you want to know if there is something at the other end you need to add more signals.

In "classical RS232" this is typically done by signals like DSR and DTR, and possibly by the CD signal.

You can of-course, as has been suggested above, have the other end send "I'm here!" pings periodically or upon user action. You listen for them in the AVR and when you hear one you know that the other end is connected at that time. There is a problem in determining when the other end is not connected any more, though.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pings have been in the news a lot in the last 4 weeks.

Imagecraft compiler user