• Navigation überspringen
  • Zur Navigation
  • Zum Seitenende
Organisationsmenü öffnen Organisationsmenü schließen
Friedrich-Alexander-Universität Lehrstuhl für Informatik 4 (Systemsoftware)
  • FAUZur zentralen FAU Website
  1. Friedrich-Alexander-Universität
  2. Technische Fakultät
  3. Department Informatik
Suche öffnen
  • English
  • Campo
  • StudOn
  • FAUdir
  • Stellenangebote
  • Lageplan
  • Hilfe im Notfall
  1. Friedrich-Alexander-Universität
  2. Technische Fakultät
  3. Department Informatik
Friedrich-Alexander-Universität Lehrstuhl für Informatik 4 (Systemsoftware)
Menu Menu schließen
  • Lehrstuhl
    • Team
    • Aktuelles
    • Kontakt und Anfahrt
    • Leitbild
    • 50-jähriges Jubiläum
    Portal Lehrstuhl
  • Forschung
    • Forschungsbereiche
      • Betriebssysteme
      • Confidential Computing
      • Eingebettete Systemsoftware
      • Verteilte Systeme
    • Projekte
      • AIMBOS
      • BALu
      • BFT2Chain
      • DOSS
      • Mirador
      • NEON
      • PAVE
      • ResPECT
      • Watwa
    • Projektkampagnen
      • maRE
    • Seminar
      • Systemsoftware
    Portal Forschung
  • Publikationen
  • Lehre
    • Sommersemester 2025
      • Applied Software Architecture
      • Ausgewählte Kapitel der Systemsoftware
      • Betriebssystemtechnik
      • Projekt angewandte Systemsoftwaretechnik
      • System-Level Programming
      • Systemnahe Programmierung in C
      • Systemprogrammierung 1
      • Verteilte Systeme
    • Wintersemester 2024/25
      • Betriebssysteme
      • Middleware – Cloud Computing
      • Systemprogrammierung 2
      • Verlässliche Echtzeitsysteme
      • Virtuelle Maschinen
      • Web-basierte Systeme
    Portal Lehre
  • Examensarbeiten
  1. Startseite
  2. Extern

Extern

Bereichsnavigation: Lehre
  • Systemnahe Programmierung in C (für Wiederholer)
    • SPiCboard
      • Bauanleitung
        • Programmieren im CIP
          • libspicboard-Doku
            • SPiC-IDE
              • SPiCsim
                • FAQ
                  • Projekte
                  • Prüfung
                    • Evaluation
                      • Linux libc-Doku
                        • Intern

                        SPiCboard

                        Files | Enumerations | Functions
                        Serial Console

                        In- and output using a serial console. More...

                        Files

                        file  console.h
                         

                        Enumerations

                        enum  CONSOLE_PARITY { PARITY_DISABLED , PARITY_EVEN , PARITY_ODD }
                         Parity bit types. More...
                         

                        Functions

                        int8_t sb_console_connect (uint32_t baud, CONSOLE_PARITY parity, uint8_t stopbits)
                         Connect to serial console. More...
                         
                        int8_t sb_console_connect_default (void)
                         Connect to serial console with default settings. More...
                         
                        char sb_console_getChar ()
                         Read the next character. More...
                         
                        char * sb_console_getString (char *string, uint16_t size)
                         Read a line into the buffer. More...
                         
                        int8_t sb_console_putChar (char character)
                         Prints a single character. More...
                         
                        int8_t sb_console_putString (const char *string)
                         Writes the string and a trailing newline. More...
                         
                        int8_t sb_console_putStringFromFlash (const __flash char *string)
                         Writes the string and a trailing newline. More...
                         

                        Detailed Description

                        In- and output using a serial console.

                        This adds the ability to print and read from a connected serial console (via USB). You can use the primitives supplied by this module or even printf and scanf.

                        In Atmel Studio 7 select Menu "Tools" and choose "Data Visualizer". Click on sidebar "Configuration" In frame "Modules" expand "External Connection" and select "Serial Port" Configure "Serial Port Control Panel":

                        • choose the correct interface (something like "mEDBG Virtual COM Port (COM4)"
                        • set the "Baud rate" to the same value as the "BAUD_RATE" macro (by default 38400)
                        • choose correct "Parity" (default "disabled") and "Stop bits" (default "1")
                        • check "DTR" and "Open Terminal" (and "RTS" on slow systems) Click "Connect"

                        In Linux you can try to connect to the console using the libspicboard make target "console":

                        Warning
                        Cannot be used in conjunction with any other serial communication (including Serial Communication )
                        Using printf/scanf (and derived functions) will consume a noticeable amount of flash memory!

                        Enumeration Type Documentation

                        enum CONSOLE_PARITY

                        Parity bit types.

                        Enumerator
                        PARITY_DISABLED 

                        parity bit disabled

                        PARITY_EVEN 

                        use even parity bit

                        PARITY_ODD 

                        use odd parity bit

                        Function Documentation

                        int8_t sb_console_connect ( uint32_t  baud,
                        CONSOLE_PARITY  parity,
                        uint8_t  stopbits 
                        )

                        Connect to serial console.

                        Specify the baud rate, parity type and number of stop bits and initiate a connection using the serial port (USART)

                        Parameters
                        baudbaud rate for serial connection
                        paritypairty type (even/odd) if enabled
                        stopbitsnumber of stop bits (1 or 2)
                        Return values
                        0connection successfully set up
                        -1Baud rate achieved is higher than allowed
                        -2Baud rate achieved is lower than allowed
                        -3Baud rate value overflow
                        -4;invalid stop bit count
                        int8_t sb_console_connect_default ( void  )

                        Connect to serial console with default settings.

                        Connect with 38400 baud, no parity and single stop bit to a serial console.

                        This is automatically used for the sb_console_* functions if sb_console_connect was not called before.

                        Return values
                        0connection successfully set up
                        -1Baud rate achieved is higher than allowed
                        -2Baud rate achieved is lower than allowed
                        -3Baud rate value overflow
                        -4;invalid stop bit count
                        char sb_console_getChar ( )

                        Read the next character.

                        Invalid read operations (end of file) will return '\0'

                        Return values
                        characterread from console
                        char* sb_console_getString ( char *  string,
                        uint16_t  size 
                        )

                        Read a line into the buffer.

                        This function reads in at most one less than size characters and stores them into the buffer pointed to by the char array. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte (\0) is stored after the last character in the buffer.

                        Parameters
                        stringpointer to buffer
                        sizesize of buffer
                        Return values
                        stringon success
                        NULLon error or when end of file occurs while no characters have been read
                        int8_t sb_console_putChar ( char  character)

                        Prints a single character.

                        Parameters
                        charactercharacter to print
                        Return values
                        -1on error
                        0on success
                        int8_t sb_console_putString ( const char *  string)

                        Writes the string and a trailing newline.

                        Parameters
                        stringstring to print
                        Return values
                        -1on error
                        0on success
                        int8_t sb_console_putStringFromFlash ( const __flash char *  string)

                        Writes the string and a trailing newline.

                        Parameters
                        stringstring from flash memory to print
                        Return values
                        -1on error
                        0on success
                        Friedrich-Alexander-Universität
                        Erlangen-Nürnberg

                        Schlossplatz 4
                        91054 Erlangen
                        • Impressum
                        • Datenschutz
                        • Barrierefreiheit
                        • Facebook
                        • RSS Feed
                        • Xing
                        Nach oben