Page 1 of 1

ANSI Console on

Posted: Thu Nov 21, 2013 3:01 pm
by jafrey
Apologies if this is too basic for 'code samples' but it's been a long time since I used C and still in the learning process with Chibi. My development board is a STM32F4Discovery. Hopefully some other beginners can find this useful.

My end goal is to create a ANSI compatible console so that rather than a just a basic 'run command' interface it's more of a 'GUI' (or at least building blocks to do so.

First Milestone: Print the number of the serial port and an incrementing number on ALL serial. I took my Usb<->Serial device and poked around all of the called out pins and, much to my surprise, it worked!

Code: Select all

        
        // Activates the UART driver 1, PA9(TX) and PA10(RX) are routed to USART1.
        // Activates the UART driver 2, PA2(TX) and PA3(RX) are routed to USART2.
        // Activates the UART driver 3, PB10(TX) and PB11(RX) are routed to USART3.
        // Activates the UART driver 4, PC10(TX) and PC11(RX) are routed to UART4.
        // Activates the UART driver 5, PC12(TX) and PD2(RX) are routed to UART5.
        // Activates the UART driver 6, PC6(TX) and PC7(RX) are routed to USART6.


Code: Select all

        
while (TRUE) {
                i++;
                if (SDU1.config->usbp->state == USB_ACTIVE) {
                        chprintf((BaseSequentialStream *)&SDU1, "Serial USB: %d\r\n", i);
                }
                chprintf((BaseSequentialStream *)&SD1, "Serial 1: %d\r\n", i);
                chprintf((BaseSequentialStream *)&SD2, "Serial 2: %d\r\n", i);
                chprintf((BaseSequentialStream *)&SD3, "Serial 3: %d\r\n", i);
                chprintf((BaseSequentialStream *)&SD4, "Serial 4: %d\r\n", i);
                chprintf((BaseSequentialStream *)&SD5, "Serial 5: %d\r\n", i);
                chprintf((BaseSequentialStream *)&SD6, "Serial 6: %d\r\n", i);
                chThdSleepMilliseconds(1000);
        }


Milestone 2: Print out different ANSI escape sequences to change the color, background and font. http://ascii-table.com/ansi-escape-sequences.php

Picture of how it appears in 2 different consoles with default settings. Eclipse terminal is on the left (white background), PuTTY is on the right (black background)
ImageImage

Re: ANSI Console on

Posted: Thu Nov 21, 2013 3:52 pm
by Giovanni
Hi,

You mean creating something like curses in UNIX? http://en.wikipedia.org/wiki/Curses_%28 ... library%29

Giovanni

Re: ANSI Console on

Posted: Thu Nov 21, 2013 5:57 pm
by jafrey
Giovanni wrote:You mean creating something like curses in UNIX? http://en.wikipedia.org/wiki/Curses_%28 ... library%29


Similar. I plan on using chibiOS to create an engine controller. I would like to make a terminal interface similar to this for some of my tuning work: http://www.youtube.com/watch?feature=pl ... XMqQKf_F3U

Re: ANSI Console on

Posted: Fri Nov 29, 2013 12:47 am
by mobyfab
Really nice, good job! :)