FreeRTOS+CLI beginner

Hello everyone, I am a beginner learning to use FreeRTOS+CLI. I am using Atmel Studio 6.2 and have already started with one of the example projects which demonstrate the functionality of FreeRTOS+CLI on SAM4S-EK. I am now trying to understand how everything is linked together since the contents of the project are huge. I was wondering if someone could guide me as to how should I create a simple command just to, say printing something out on the PC terminal, what are the necessary parts of doing so. Secondly, I would like to ask if FreeRTOS uses printf in its structure somewhere to write to UART? If this is so, I would like to ask which files are necessary for printf to function? What I have at the moment is a GCC C Executable project in Atmel Studio 6.2 I have included the FreeRTOS source files and it is running properly. I have also configured the UART interface on SAM4S and am able to send a character to PC terminal by directly writing into the Transmit register of UART. I would like to continue from this point on-wards to implement a CLI. Thanks in advance. Regards, Owais

FreeRTOS+CLI beginner

To me this question is not about FreeRTOS but about how to design an application. There are many, many simple programs that implement a Command Level Interface. If you are unfamiliar with creating one find a simple program and study the layers and the technique. The CLI requires parsing some strings, doing something and outputting some sort of feedback. The ‘Hello World’ sample is half of that. You have to know many things that are outside of the scope of FreeRTOS support. How does your connection to your device work? How do you get and send data from the devices involved? FreeRTOS doesn’t directly create any hardware specific solutions or interfaces. Printf and most of the application functions are implemented in separate libraries the must be included in your project, usually by linking. They have some good samples for the most common platforms with sample device drivers that may suit your needs. Knowing how to link a project is also not a FreeRTOS specific task. It depends on what your are using for a development system, what modules you want to include in your project, your hardware constraints and what your goals are. Compiling and linking are often done for you in development systems but knowing how to directly manage them (in case you need to) is required for embedded development.

FreeRTOS+CLI beginner

As Mark says – where you direct printf() to is application specific and not dependent on FreeRTOS. FreeRTOS does not itself use printf() – and I don’t think you would expect a system like FreeRTOS to. The Atmel software framework has various functions for writing output to a UART or other terminal. If you want something really light weight you can look for a file called printf-stdarg.c in the FreeRTOS/Demo directory – you will find lots of copies of it. At the top of the file you will see that putchar() is stubbed out as follows:
#define putchar(c) c
If you comment out that line and already have the UART working then you can provide your own implementation of putchar() that simply writes ‘c’ to the UART. That is crude (not fast) but effective and easy to implement.
I was wondering if someone could guide me as to how should I create a simple command just to, say printing something out on the PC terminal
How to create your own command is documented on the website. Go to http://www.freertos.org/cli then click on each step in the diagram you see in turn. How you actually receive characters to pass to the CLI and how you write characters generated to the CLI to the terminal is application specific – but sounds like you want the characters to go to the UART in your case. The download includes examples that write to a UART, as well as other examples that write to a UDP or TCP port. Regards.

FreeRTOS+CLI beginner

Thank you very much. I was able to follow the above procedure and finally defined my own function into putchar and now I can see strings on the terminal. I will go through the theory of CLI and hopefully start implementing it with some basic understanding of its functionality. Yes I want to make the CLI for UART. I am looking into the common examples that came with FreeRTOS download named UARTCommanConsole.c, there are functions such as vSerialPutString and xSerialPutChar xSerialGetChar, are these also part of FreeRTOS+CLI? If so, where can I find their implementation? Regards, Owais

FreeRTOS+CLI beginner

vSerialPutString and xSerialPutChar xSerialGetChar, are these also part of FreeRTOS+CLI?
No – they are the functions you will have to provide to actually perform the input and output – as per previous posts in this thread. Regards.

FreeRTOS+CLI beginner

Okay thanks for clearing that again. Regards, Owais.

FreeRTOS+CLI beginner

Hello, I was wondering if there is support for float in any of the FreeRTOS aware printf. I am already using printf-stdarg.c from one of the demo examples provided with FreeRTOS download. If there is some code that I could implement in this file for floats please let me know. Thanks. Regards, Owais

FreeRTOS+CLI beginner

If the file does not already have float support (which I don’t think it does) then you would have to add it in yourself – otherwise use a different implementation. Maybe revert back to the compilers own version. Be aware however that if you are using GCC then adding floating point support to printf() will bring in a lot of code, making your binary image much bigger. Regards.

FreeRTOS+CLI beginner

I have checked the file and it does not have float support. However, I understand that including float support will increase the binary size, therefore i asked if there is an existing code which can be used for float support so to not increase the size too much and still be able to use it in freertos. Regards, Owais

FreeRTOS+CLI beginner

The reason for the limited version of printf is so that just using printf doesn’t pull in big pieces of the floating point support library. If you are already using floating point, you can just use the standard printf routine provided by the complier. There isn’t really any FreeRTOS awareness needed here. The standard library should have a function you define to provide output for standard-out.

FreeRTOS+CLI beginner

If you don’t need general float support but just need limited support you could make your own ‘fake’ float sprintf routine using divide and modulo… this is what I ended up doing when I needed to print some float values with three decimals, that were limited in range to about +/- 10.0. This would probably only be practical if you didn’t need “E” notation…. On Sep 1, 2014, at 5:09 AM, “Owais” owaisfazal@users.sf.net wrote:
I have checked the file and it does not have float support. However, I understand that including float support will increase the binary size, therefore i asked if there is an existing code which can be used for float support so to not increase the size too much and still be able to use it in freertos. Regards, Owais FreeRTOS+CLI beginner Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freertos/discussion/382005/ To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/