Code: Select all
#include "ch.h"
#include "hal.h"
#include "chprintf.h"
/* Periodic thread for reading data */
static THD_WORKING_AREA(waRead, 128);
static THD_FUNCTION(Thread,arg) {
(void)arg;
chRegSetThreadName("thread_callback");
while (TRUE){
/* This will wait for a character to be received */
uint8_t c = sdGet(&SD1); //get the caracter
sdPut(&SD2, c); // put the caracter on sd2
}
}
.....
halInit();
chSysInit();
char AT[] = "AT\r"; // AT COMMAND
while (true) {
sdWrite(&SD1, (uint8_t *) AT,3); // va bene
}
}
All Work Well, if i use this code don't work, i can't store the answer gsm shield this is the code:
Code: Select all
#define BUFFER_SIZE 128
static char bufferMsg[BUFFER_SIZE];
static THD_WORKING_AREA(waRead2, 128);
static THD_FUNCTION(Thread2,arg) {
(void)arg;
int count=0;
chRegSetThreadName("thread_callback_2");
while((bufferMsg[count] = sdGet(&SD1)) != '\n' && count < BUFFER_SIZE) {
bufferMsg[count]=(char)sdGet(&SD1);
count++;
}
}
/*print buffer*/
void printBuffer(char bufferMsg[])
{
int count=0;
while((bufferMsg[count] != '\n') && (count < BUFFER_SIZE)){
sdPut(&SD2,(uint8_t)bufferMsg[count]);
count++;
}
}
....
while (true) {
sdWrite(&SD1, (uint8_t *) AT,3); //AT Command
chThdSleepMilliseconds(3000);
printBuffer(bufferMsg);
...
}
can you help me?
best regards.
A.