Simple HyperTermina example; problems with some chars

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
User avatar
AlSith
Posts: 20
Joined: Thu Oct 01, 2015 10:41 am

Simple HyperTermina example; problems with some chars

Post by AlSith »

Hi to all ..good afternoon!
I realized a simple example to use Serial Driver, in which I write a char by keyboard and read it on the terminal; I use a thread. Below the code:

Code: Select all

static SerialConfig uartCfg = { BAUDRATE, 0, 0, 0 };

static msg_t SerThd(void *arg) {
   (void)arg;
   chRegSetThreadName("Read-Write SERIAL-DATA");

   // Activates the Serial driver 2, PA2(TX) and PA3(RX) are routed to USART2, 9600 8N1.
   palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
   palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
   sdStart(&SD2, &uartCfg); // starts the serial driver with uartCfg as a config
   
   uint8_t buffer;

   while(TRUE) {
     buffer = sdGet(&SD2);

     if(strlen(buffer)>0){
       sdWrite(&SD2, (uint8_t *)stringBR, strlen(stringBR));  // in defines session there is: stringBR="\r\n";
       sdPut(&SD2, buffer);
     }

   }

   return 0;
}


there is a problem with some chars.. when I write them, i don't see:
z, r, f, v, b, n, j, . ,2 and 6 (for letters, both upper and lower case).

Someone can explain me why? Thanks.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Simple HyperTermina example; problems with some chars

Post by Giovanni »

The problem there is not related to the OS, what is the strlen of a uint8_t type?

Giovanni
User avatar
AlSith
Posts: 20
Joined: Thu Oct 01, 2015 10:41 am

Re: Simple HyperTermina example; problems with some chars

Post by AlSith »

I'm sorry Boss,

but I don't understand what do you mean..?? :shock: :shock: :? :?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Simple HyperTermina example; problems with some chars

Post by Giovanni »

This:

Code: Select all

   uint8_t buffer;

   while(TRUE) {
     buffer = sdGet(&SD2);

     if(strlen(buffer)>0){


What is it supposed to do?

Giovanni
User avatar
AlSith
Posts: 20
Joined: Thu Oct 01, 2015 10:41 am

Re: Simple HyperTermina example; problems with some chars

Post by AlSith »

Now that you mention it, maybe conceptually it isn't correct as idea, but with this instruction I meant "when the char it's been written (dimension of variable changes??), re-write out it".. :? :? :?

could you let me understand where i'm wrong :( :(
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Simple HyperTermina example; problems with some chars

Post by Giovanni »

You need a good book for the C language and to spend some time into the debugger.

I will help you by not helping you :)

Giovanni
User avatar
AlSith
Posts: 20
Joined: Thu Oct 01, 2015 10:41 am

Re: Simple HyperTermina example; problems with some chars

Post by AlSith »

:o :o ..thanks boss..!! :( :(
Post Reply