Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

[URGENT] How to receive a string from UART ?

Hi! I am only able to receive the last char from the UART and was wondering how can I receive a string from UART

HyperTerminal -> UART -> Terminal 0 (Nios II Console)

I am using Nios II C Programming I guess... Please Help Me! Thank You!

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi, which board, which NIOS II program, which UART driver ?

    In almost programs for beginner ("getting started", tutorials), every time you send a character to UART, it triggers an interruption and copy it to the Nios II Terminal.

    A string is a suite of characters.

    So what is the problem ? You want Terminal to print the entire string ? You have to memorize the characters until a Carrier Return is received and after print it to terminal...

    Regards.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi, which board, which NIOS II program, which UART driver ?

    In almost programs for beginner ("getting started", tutorials), every time you send a character to UART, it triggers an interruption and copy it to the Nios II Terminal.

    A string is a suite of characters.

    So what is the problem ? You want Terminal to print the entire string ? You have to memorize the characters until a Carrier Return is received and after print it to terminal...

    Regards.

    --- Quote End ---

    Hi! I am able to receive a string from the HyperTerminal and send it toDE2_115 Altera Board using C Programming but I am unable to detect the carriage return ? i compare it with \r but it didn't get into the loop.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I tried to compare with the message I get but it still doesn't works...

    is there any other way?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Are you beginner in C program ?

    Comparing strings in C is not so easy as comparing integers. Keep in mind that a string in C is terminated by a NULL character '\0'

    You can compare a suite of characters.

    Before comparing, just try to simply print the received strings.

    The output may be buffered. So "printf" seems to not work. You can "force" the print by adding a function that looks like "flush()".

    could you please tell us what you exactly want to do ?