Page 1 of 1

Simple HyperTermina example; problems with some chars

Posted: Wed Oct 14, 2015 1:32 pm
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.

Re: Simple HyperTermina example; problems with some chars

Posted: Wed Oct 14, 2015 1:41 pm
by Giovanni
The problem there is not related to the OS, what is the strlen of a uint8_t type?

Giovanni

Re: Simple HyperTermina example; problems with some chars

Posted: Wed Oct 14, 2015 2:04 pm
by AlSith
I'm sorry Boss,

but I don't understand what do you mean..?? :shock: :shock: :? :?

Re: Simple HyperTermina example; problems with some chars

Posted: Wed Oct 14, 2015 2:06 pm
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

Re: Simple HyperTermina example; problems with some chars

Posted: Wed Oct 14, 2015 2:37 pm
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 :( :(

Re: Simple HyperTermina example; problems with some chars

Posted: Wed Oct 14, 2015 3:29 pm
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

Re: Simple HyperTermina example; problems with some chars

Posted: Wed Oct 14, 2015 4:20 pm
by AlSith
:o :o ..thanks boss..!! :( :(