Sorgente in C per comunicare in FBUS coi Nokia e inviare SMS?

C'e' un link in fondo a questa pagina:
http://www.mcselec.com/index.php?option=com_content&task=view&id=88&Itemid=57

Lo zip contiene un file C.

è una richiesta di aiuto per il porting o cosa?

E' un'informazione fornita alla comunità Arduino, ognuno puo' farne quello che vuole.

Sono riuscito a compilare il sorgente nell'IDE arduino, ma facendo queste modifiche:

  • eliminare tutte le ripetizioni di "n61_"
  • eliminare #include <string.h>
  • sostituire '"' con '"' (apice-virgolette-apice) in riga 226
  • riga 298: sostituire "return" con "return 0"
  • riga 305: sostituire msleep(1) con delay(1)
  • riga 523 e 786: aggiungere unsigned prima di char

Ora bisogna vedere... se questo sorgente serve a qualcosa!
In teoria dovrebbe bastare collegare i due pin 0 e 1 di Arduino a TX e RX di un qualunque cell Nokia per inviare e ricevere SMS!

Qui ci sono varie piedinature:

Questo è il mio sorgente (suddiviso in 3 messaggi senno' non c'entra):

#define N61MODE_SYNC	0
#define N61MODE_DEST	1
#define N61MODE_SOURCE	2
#define N61MODE_TYPE	3
#define N61MODE_UNKNOWN	4
#define N61MODE_SIZE	5
#define N61MODE_DATA	6

#define N61STATE_WAIT	0
#define N61STATE_PROC	1
#define N61STATE_GOOD	2
#define N61STATE_BAD	3

#define N61MAXSIZE	120

#define N61VALID_1H	0x0b
#define N61VALID_6H	0x47
#define N61VALID_24H	0xa7
#define N61VALID_72H	0xa9
#define N61VALID_1W	0xad
#define N61VALID_MAX	0xff

struct MESSAGE
{
	int dest;
	int source;
	int type;
	int unknown;
	int size;
	unsigned char dat[256];
	int cs[2];
};

struct MESSAGE tmp, buf;
int seqnum = 0;
int prevseq = 0;
int (*serial)(int cmd, unsigned char c);
int mode = 0;
int atbyte = 0;
int datp = 0;
int readsize = 0;
int readbase = 0;
int state;
int multiple;
char smsc[32];
int msgqueuesize;
char msgqueue[4][161];
char msgqueue2[4][17];
int ack, gotmsg, waittype;
int blocked;


// ** translate table taken directly from gnokii **

unsigned char transtable[] = {

	/* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */
	/* Characters in hex position 10, [12 to 1a] and 24 are not present on
		latin1 charset, so we cannot reproduce on the screen, however they are
		greek symbol not present even on my Nokia */

	'@',  0xa3, '

Non lo posso provare finche' non saldo un paio di fili a un cellulare... pero' almeno si compila! Ho dovuto fare qualche altro cambiamento... ma non so se vada bene, perche' io con char, char * e stringhe ci litigo, o meglio, non ci capisco niente. L' unsigned char* di sendmsg ora è diventato semplice char * , senno' non funzionava... ma immagimo che questo limiti a 127 il numero di caratteri di un SMS! Devo capire perche' con l'unsigned non compilava...

Comunque, ho aggiunto l'inizializzazione della seriale e l'invio di un messaggio, rispetto al sorgente iniziale.
Se funziona... siamo a cavallo! :),  0xa5, 0xe8, 0xe9, 0xf9, 0xec,
0xf2, 0xc7, '\n', 0xd8, 0xf8, '\r', 0xc5, 0xe5,
'?',  '_',  '?',  '?',  '?',  '?',  '?',  '?',
'?',  '?',  '?',  '?',  0xc6, 0xe6, 0xdf, 0xc9,
' ',  '!',  '"', '#',  0xa4,  '%',  '&',  ''',
'(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',
'0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
'8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',
0xa1, 'A',  'B',  'C',  'D',  'E',  'F',  'G',
'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
'X',  'Y',  'Z',  0xc4, 0xd6, 0xd1, 0xdc, 0xa7,
0xbf, 'a',  'b',  'c',  'd',  'e',  'f',  'g',
'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',
'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
'x',  'y',  'z',  0xe4, 0xf6, 0xf1, 0xfc, 0xe0
};

// **** Functions            ****

void init(int (*func)(int cmd, unsigned char c)); // initialize the driver
int smssend(char *dest, char *msg); // send SMS
int smsrecv(char *dest, char *msg); // recv SMS
int smsqueue(); // check the recv queue
void update(); // keep the driver in sync

// **** Functions - internal ****

void block(); // protect during update
void unblock(); // unprotect

void update_main(); // main update
void update_internal(); // internal version of
//   update()

void serial_send(unsigned char c); // send byte
unsigned char serial_recv(); // recv byte
unsigned char serial_isdata(); // check for serial data
void serial_delay(); // wait 1 millisecond

int nextseq(); // get next sequence number
int sendframe(int type, int size, unsigned char *data); // send frame
int sendmsg(int type, int size,  char *data); // send message
void sendack(int type, int seqnum); // send acknowledgement

void ackwait(int x); // wait for ack
void wait(int x); // wait for a message

void addchar(char *str, char c); // strcat() but for chars
void bcd(char *dest, char *s); // encode SMSC number
void bcd2(char *dest, char *s); // encode phone number
char *unbcd(unsigned char *dat); // decode SMSC number
char *unbcd2(unsigned char *dat); // decode phone number

void pack7(char *dest, char *s); // pack when sending
char *unpack7(unsigned char *dat, int len); // unpack when received

unsigned char gettrans(unsigned char c); // translate char
void addmsg(char *dest, char *msg); // add a received SMS
//   to the queue

void procmsg(struct MESSAGE *msg); // process incoming message

void getstatus(); // request phone status
void getsmsc(); // request SMSC
void delsms(int x); // delete SMS message
int smssendfull(char *smsc, char *dest, char *msg); // send SMS via SMSC


Non lo posso provare finche' non saldo un paio di fili a un cellulare... pero' almeno si compila! Ho dovuto fare qualche altro cambiamento... ma non so se vada bene, perche' io con char, char * e stringhe ci litigo, o meglio, non ci capisco niente. L' unsigned char* di sendmsg ora è diventato semplice char * , senno' non funzionava... ma immagimo che questo limiti a 127 il numero di caratteri di un SMS! Devo capire perche' con l'unsigned non compilava...

Comunque, ho aggiunto l'inizializzazione della seriale e l'invio di un messaggio, rispetto al sorgente iniziale.
Se funziona... siamo a cavallo! :)

Seconda parte del codice:

// ** Code **
        int myhandler(int cmd, unsigned char c)
        {
            if(cmd == 0) {
                serial_send(c);          // send c out the port
                return 0;
            }
            else if(cmd == 1)
                return serial_recv();    // return the next byte in queue
            else if(cmd == 2)
                return serial_isdata();  // return zero if queue is empty
            else if(cmd == 3)
                delay(1);               // delay for 1 millisecond
        }

unsigned char gettrans(unsigned char c)
{
	unsigned char n;

	if(c == '?')
		return 0x3f;

	for(n = 0; n < 128; ++n) {
		if(transtable[n] == c)
			return n;
	}

	return 0x3f;
}

void block()
{
	blocked = 1;
}

void unblock()
{
	blocked = 0;
}

void update()
{
	if(!blocked) {
		block();
		update_main();
		unblock();
	}
}

void update_internal()
{
	update_main();
}

void serial_send(unsigned char c)
{
	//serial(0, c);
Serial.print(c);
}

unsigned char serial_recv()
{
return Serial.read();	
  //return serial(1, 0);
}

unsigned char serial_isdata()
{
        return Serial.available();
	//return serial(2, 0);
}

void serial_delay()
{
  delay(1);
	//serial(3, 0);
}

void ackwait(int x)
{
	int n;

	for(n = 0; n < x; ++n) {
		update_internal();
		serial_delay();
		if(ack)
			return;
	}
}

void wait(int x)
{
	int n;

	for(n = 0; n < x; ++n) {
		update_internal();
		serial_delay();
		if(gotmsg)
			return;
	}
}

void addmsg(char *dest, char *msg)
{
	int n;

	// clip args for safety. in theory not necessary
	msg[160] = 0;
	dest[16] = 0;

	// add the message
	n = msgqueuesize;
	strcpy(msgqueue[n], msg);
	strcpy(msgqueue2[n], dest);
	++msgqueuesize;
}

int smsrecv(char *dest, char *msg)
{
	int n;

	block();
	n = msgqueuesize;

	if(n <= 0) {
		unblock();
		return 0;
	}

	strcpy(msg, msgqueue[0]);
	strcpy(dest, msgqueue2[0]);
	--msgqueuesize;

	for(n = 0; n < msgqueuesize; ++n) {
		strcpy(msgqueue[n], msgqueue[n+1]);
		strcpy(msgqueue2[n], msgqueue2[n+1]);
	}

	unblock();

	return 1;
}

int smsqueue()
{
	return msgqueuesize;
}

int sendframe(int type, int size, unsigned char *data)
{
	unsigned char buf[256];
	int at, n, check, len;
	unsigned short *p;

	at = 0;

	// build header
	buf[at++] = 0x1e;		// message startbyte
	buf[at++] = 0x00;		// dest: phone
	buf[at++] = 0x0c;		// source: PC
	buf[at++] = type;
	buf[at++] = 0x00;
	buf[at++] = size;

	// add data
	for(n = 0; n < size; ++n)
		buf[at++] = data[n];

	// if odd numbered, add filler byte
	if(size % 2) {
		buf[at++] = 0x00;
	}

	// calculate checksums
	check = 0;
	p = (unsigned short *)buf;
	len = at / 2;
	for(n = 0; n < len; ++n)
		check ^= p[n];
	p[n] = check;
	at += 2;

	// send the message!
	for(n = 0; n < at; ++n) {
		serial_send(buf[n]);
	}
}

int nextseq()
{
	int n;

	n = seqnum;
	prevseq = n;

	++seqnum;
	seqnum &= 7;

	return (n + 0x40);
}

int sendmsg(int type, int size,  char *data)
{
	unsigned char buf[N61MAXSIZE + 2];
	unsigned char num, lastsize;
	int n;
	int len;

	num = (size + N61MAXSIZE - 1) / N61MAXSIZE;
	lastsize = size % N61MAXSIZE;

	for(n = 0; n < num;) {
		if(n + 1 == num)
			len = lastsize;
		else
			len = N61MAXSIZE;

		// get current chunk
		memcpy(buf, data + (n * N61MAXSIZE), len);
		buf[len] = num - n;
		buf[len+1] = nextseq();
		if(n)
			buf[len+1] &= 7;

		ack = 0;
		sendframe(type, len + 2, buf);
		ackwait(1000);
		if(ack)
			++n;
	}
}

Terza parte:

void sendack(int type, int seqnum)
{
	unsigned char buf[2];

	buf[0] = type;
	buf[1] = seqnum;

	sendframe(0x7f, 2, buf);
}

void update_main()
{
	int n;
	unsigned char c;

	while(serial_isdata()) {
		c = serial_recv();

		// calculate the checksums
		tmp.cs[atbyte & 1] ^= c;

		// act on the byte
		switch(mode) {
			case N61MODE_SYNC:
				if(c == 0x1e) {
					if(!multiple) {
						memset(tmp.dat, 0, 256);
						atbyte = 0;
					}

					tmp.cs[0] = 0x1e;
					tmp.cs[1] = 0;

					mode = N61MODE_DEST;
				}
				break;

			case N61MODE_DEST:
				tmp.dest = c;
				mode = N61MODE_SOURCE;
				break;

			case N61MODE_SOURCE:
				tmp.source = c;
				mode = N61MODE_TYPE;
				break;

			case N61MODE_TYPE:
				tmp.type = c;
				mode = N61MODE_UNKNOWN;
				break;

			case N61MODE_UNKNOWN:
				tmp.unknown = c;
				mode = N61MODE_SIZE;
				break;

			case N61MODE_SIZE:
				if(multiple)
					tmp.size += c - 2;
				else {
					tmp.size = c;
					datp = 0;
				}

				mode = N61MODE_DATA;

				// calculate the number of bytes to read
				n = tmp.size % 2;

				// message size + filler + checksums
				readsize = tmp.size + n + 2;

				break;

			case N61MODE_DATA:
				n = datp++;
				if(n > 255) {
					multiple = 0;
					mode = N61MODE_SYNC;
					break;
				}

				tmp.dat[n] = c;	// get the byte

				// are we done yet?
				if(n >= readsize - 1) {
					// checksums ok?
					if(tmp.cs[0] == tmp.cs[1] && tmp.cs[0] == 0) {
						// don't want to ACK on an ACK
						if(tmp.type != 0x7f) {
							sendack(tmp.type, tmp.dat[tmp.size-1] & 0x0f);

							if(tmp.size > 1 && tmp.dat[tmp.size-2] != 0x01) {
								datp -= 4;  // back up past checksums and seqinfo
								++multiple;
							}
							else
								multiple = 0;
						}

						if(!multiple || tmp.type == 0x7f) {
							multiple = 0;
							memcpy(&buf, &tmp, sizeof(struct MESSAGE));
							procmsg(&buf);
						}
					}
					else {
						// bad!
						multiple = 0;
					}
					mode = N61MODE_SYNC;
				}

			default:
				break;
		}

		++atbyte;
	}
}

void getstatus()
{
	 char buf[32];

	buf[0] = 0x00;
	buf[1] = 0x01;
	buf[2] = 0x00;

	buf[3] = 0x6d;

	sendmsg(0x11, 4, buf);
}

void getsmsc()
{
	 char buf[32];
	int x, n;

	buf[0] = 0x00;
	buf[1] = 0x01;
	buf[2] = 0x00;

	buf[3] = 0x33;
	buf[4] = 0x64;

	buf[5] = 0x01;

	// "do" or "try", there is no "do not"
	while(1) {
		// send off the request
		state = N61STATE_PROC;

		gotmsg = 0;
		waittype = 2;
		sendmsg(0x02, 6, buf);

		wait(1000);
		if(state == N61STATE_GOOD)
			break;
	}
}

void delsms(int x)
{
	 char buf[32];

	buf[0] = 0x00;
	buf[1] = 0x01;
	buf[2] = 0x00;

	buf[3] = 0x0a;
	buf[4] = 0x02;
	buf[5] = x;

	sendmsg(0x14, 6, buf);
}

void bcd(char *dest, char *s)
{
	int size, x, y, n, hi, lo;

	if(s[0] == '+') {
		dest[1] = 0x91;
		++s;
	}
	else
		dest[1] = 0x81;

	x = 0;
	y = 2;
	while(s[x]) {
		lo = s[x++] - '0';
		if(s[x])
			hi = s[x++] - '0';
		else
			hi = 0x0f;

		n = (hi << 4) + lo;
		dest[y++] = n;
	}
	dest[0] = y - 1;
}

void bcd2(char *dest, char *s)
{
	int size, x, y, n, hi, lo;

	if(s[0] == '+') {
		dest[1] = 0x91;
		++s;
	}
	else
		dest[1] = 0x81;

	x = 0;
	y = 2;
	while(s[x]) {
		lo = s[x++] - '0';
		if(s[x])
			hi = s[x++] - '0';
		else
			hi = 0x0f;

		n = (hi << 4) + lo;
		dest[y++] = n;
	}
	dest[0] = strlen(s);
}

void pack7(char *dest, char *s)
{
	int len;
	unsigned char c;
	unsigned short *p, w;
	int at;
	int shift;
	int n, x;

	len = strlen(s);
	x = (len * 8) / 7;
	for(n = 0; n < x; ++n)
		dest[n] = 0;

	shift = 0;
	at = 0;
	w = 0;
	for(n = 0; n < len; ++n) {
		p = (unsigned short *)(dest + at);
		w = gettrans(s[n]) & 0x7f;
		w <<= shift;

		*p |= w;

		shift += 7;
		if(shift >= 8) {
			shift &= 7;
			++at;
		}
	}
}

int smssendfull(char *smsc, char *dest, char *msg)
{
	 char buf[256];
	int n;

	// standard frame data header
	buf[0] = 0x00;
	buf[1] = 0x01;
	buf[2] = 0x00;

	// send sms ?
	buf[3] = 0x01;
	buf[4] = 0x02;
	buf[5] = 0x00;

	// smsc
	memset(buf + 6, 0, 12);
	bcd(buf + 6, smsc);

	// TPDU ?
	buf[18] = 0x11;

	// misc
	buf[19] = 0x00;	// message ref
	buf[20] = 0x00;	// protocol ID
	buf[21] = 0xf1;	// data coding scheme (non-flash)

	// message size
	buf[22] = strlen(msg);

	// destination
	memset(buf + 23, 0, 12);
	bcd2(buf + 23, dest);

	// validity period
	buf[35] = N61VALID_24H;

	// filler
	buf[36] = 0;
	buf[37] = 0;
	buf[38] = 0;
	buf[39] = 0;
	buf[40] = 0;
	buf[41] = 0;

	// the string
	pack7(buf + 42, msg);

	// try till we get some response
	while(1) {
		state = N61STATE_PROC;

		gotmsg = 0;
		waittype = 1;
		sendmsg(0x02, 42 + strlen(msg), buf);

		wait(5000);
		if(state != N61STATE_PROC)
			break;
	}

	if(state == N61STATE_GOOD)
		return 1;

	return 0;
}

int smssend(char *dest, char *msg)
{
	int n;

	block();
	n = smssendfull(smsc, dest, msg);
	unblock();

	return n;
}

void addchar(char *str, char c)
{
	int n;

	n = strlen(str);
	str[n] = c;
	str[n+1] = 0;
}

char *unbcd(unsigned char *dat)
{
	static char buf[32];
	int len;
	int n, x;

	buf[0] = 0;
	len = dat[0];

	if(dat[1] == 0x91) {
		addchar(buf, '+');
	}

	for(n = 0; n < len-1; ++n) {
		x = dat[n+2] & 0x0f;
		if(x < 10)
			addchar(buf, '0' + x);
		x = (dat[n+2] >> 4) & 0x0f;
		if(x < 10)
			addchar(buf, '0' + x);
	}

	return buf;
}

char *unbcd2(unsigned char *dat)
{
	static char buf[32];
	int len;
	int n, x;
	int at;

	buf[0] = 0;
	len = dat[0];

	if(dat[1] == 0x6f || dat[1] == 0x91) {
		addchar(buf, '+');
	}

	at = 2;
	for(n = 0; n < len; ++n) {
		x = dat[at] & 0x0f;
		if(x < 10)
			addchar(buf, '0' + x);
		++n;
		if(!(n < len))
			break;
		x = (dat[at] >> 4) & 0x0f;
		if(x < 10)
			addchar(buf, '0' + x);
		++at;
	}

	return buf;
}

char *unpack7(unsigned char *dat, int len)
{
	static char buf[256];
	unsigned short *p, w;
	unsigned char c;
	int n;
	int shift;
	int at;

	shift = 0;
	at = 0;
	buf[0] = 0;
	for(n = 0; n < len; ++n) {
		p = (unsigned short *)(dat + at);
		w = *p;
		w >>= shift;
		c = w & 0x7f;

		shift += 7;
		if(shift & 8) {
			shift &= 0x07;
			++at;
		}

		addchar(buf, transtable[c]);
	}

	return buf;
}

void procmsg(struct MESSAGE *msg)
{
	int n, subtype;

	// check if this is a msg of interest
	subtype = 0;
	if(msg->type != 0x7f) {
		if(msg->type == 0x02) {
			if(msg->dat[3] == 0x02 || msg->dat[3] == 0x03)
				subtype = 1;
			if(msg->dat[3] == 0x10)
				subtype = 2;
			if(msg->dat[3] == 0x34)
				subtype = 3;
		}
		if(subtype == waittype)
			gotmsg = 1;
	}

	// act on it
	switch(msg->type) {
		// SMS
		case	0x02:
			if(msg->dat[3] == 0x02) {
				state = N61STATE_GOOD;
			}
			if(msg->dat[3] == 0x03) {
				state = N61STATE_BAD;
			}
			if(msg->dat[3] == 0x10) {
				addmsg(unbcd2(msg->dat + 23), unpack7(msg->dat + 42, msg->dat[22]));

				// now delete the msg
				if(msg->dat[5])
					delsms(msg->dat[5]);
			}

			// SMSC
			if(msg->dat[3] == 0x34) {
				state = N61STATE_GOOD;
				strcpy(smsc, unbcd(msg->dat+21));
			}
			break;

		case	0x7f:
			if((msg->dat[1] & 7) == prevseq)
				ack = 1;
			break;

		default:
			break;
	}
}

void init(int (*func)(int cmd, unsigned char c))
{
	int n;

	seqnum = 0;
	serial = func;
	blocked = 0;
	msgqueuesize = 0;
	multiple = 0;
	readbase = 0;

	// getsmsc
	getsmsc();
}

void setup() {
  char * destinatario = "00000000";
  char * messaggio = "Incredibile, funziona davvero!";
  Serial.begin(115200);
  init(myhandler);
  smssend(destinatario,messaggio);
}

void loop() {
}

non vorrei rimpere le uova nel paniere, ma gli array che stai utilizzando sono troppo grandi e non ci stanno nella ram di arduino.

in particolare char msgqueue[4][161]; = 4161=644byte
+
2 struttere MESSAGE che contengono unsigned char dat[256]; = 256
2=512byte

considerando che l'atmega328 ha 2k di ram... ne usi più di mezza solo con queste 2 cose. Aggiungi 128 per il buffer della seriale, variabili dichiarate dal tuo programma/questa libreria, altre librerie (in automatico il .pde importa wprogram.h che a sua volta importa un sacco di librerie)

transtable lo puoi dichiarare in un certo modo che te lo salva in eeprom (non ricordo il comando e non lo trovo)

anche alcune funzioni usando grossi array, se arduino ti pianta a caso probabilmente ha riempito la ram in una di queste chiamate.

edit: niente di grave, si può risolvere ottimizzando il codice

Ma il compilatore non si accorge di tutte queste cose?!? :~
Cmq io non saprei da che parte cominciare a ottimizzare il codice... Volontari? 8)

mmhh.. Per quel poco che ci capisco di C, mi par di capire che l'array incriminato msgqueue puo' contenere fino a 4 messaggi, e viene riempito qui:

void addmsg(char *dest, char *msg)
{
	int n;

	// clip args for safety. in theory not necessary
	msg[160] = 0;
	dest[16] = 0;

	// add the message
	n = msgqueuesize;
	strcpy(msgqueue[n], msg);
	strcpy(msgqueue2[n], dest);
	++msgqueuesize;
}

Mi pare che serva solo a poter tenere in memoria fino a 4 messaggi contemporaneamente... giusto? Ma è necessario?!?
I messaggi SMS "lunghi" non sono formati da 4 SMS brevi concatenati tramite caratteri appositi? Se è a questo che serve msgqueue, puo' essere tranquillamente eliminata!

no, il compilatore non si cura, anzi, se ne frega altamente. :grin:
prima di tutto sostituisci tutte le costanti numeriche usando i #DEFINE, in questo modo sarà più facile modificare il codice. Fai attenzione, che non è che tutti i 255 li metti in un solo define, ma li devi suddividere in base alla loro funzione.
poi fai la somma in byte di tutte le variabili globali (compresi gli array) e degli array contenuti nelle funzioni. Avrai una stima errata per rialzo dell'uso di ram della classe.

ora inizia a giocare modificando i numeri. Per esempio prima dicevi cha a causa di un errore di compilazioni, i messaggi saranno lunghi solo 128 byte... bene allora diminuisci il define della dimensione dei messaggi a 128 byte, rifai i calcoli e vedi se ci stai nella ram...

Ah e mi piacerevve un bel copia incolla dell'errore e della riga, la cose mi suona alquanto strana.

poi, sicuro di questa funzione?

void serial_delay()
{
  delay(1);
	//serial(3, 0);
}

a me non convince, mi sembra strano che serial(3, 0); sia traducibile in un delay

ps. ma in teoria funziona con tutti i nokia? se si dovrei avere qualche 3310 o simili in giro per casa.

lesto:
no, il compilatore non si cura, anzi, se ne frega altamente. :grin:

Ottimo compilatore. E meno male che chiede di specificare a quale Arduino si collega!

Ah e mi piacerebbe un bel copia incolla dell'errore e della riga, la cosa mi suona alquanto strana.

MI dava un errore di conversione da char * a unsigned char* e/o viceversa, a seconda di dove mettotolgo l'unsigned...

poi, sicuro di questa funzione?

void serial_delay()

{
 delay(1);
//serial(3, 0);
}



a me non convince, mi sembra strano che serial(3, 0); sia traducibile in un delay

Quel "serial()" è solo un dummy, nei commenti è spiegato.

ps. ma in teoria funziona con tutti i nokia? se si dovrei avere qualche 3310 o simili in giro per casa.

Piu' vecchio è, meglio è. Forse funziona persino sui cellulari che non hanno porta esterna, perche' l'FBUS serve all'assistenza per fare diagnostica e riflasharli.

jumpjack:
Ottimo compilatore. E meno male che chiede di specificare a quale Arduino si collega!

è normale, credo nessun compilatore faccia questa verifica, è un errore logico non sintattico

jumpjack:
MI dava un errore di conversione da char * a unsigned char* e/o viceversa, a seconda di dove mettotolgo l'unsigned...

problemi di puntatori. Usa l'unsigned e traccia le righe che danno errore e postale, te le sistemo (ora sto uscendo, magari domano lo faccio)

per il resto tutto ok :slight_smile:

lesto:

jumpjack:
Ottimo compilatore. E meno male che chiede di specificare a quale Arduino si collega!

è normale, credo nessun compilatore faccia questa verifica, è un errore logico non sintattico

Si', ma questo è un compilatore per un affarino con 2k di RAM, pensavo che un minimo di controllo lo facesse...

lesto:

jumpjack:
MI dava un errore di conversione da char * a unsigned char* e/o viceversa, a seconda di dove mettotolgo l'unsigned...

problemi di puntatori. Usa l'unsigned e traccia le righe che danno errore e postale, te le sistemo (ora sto uscendo, magari domano lo faccio)
per il resto tutto ok :slight_smile:

non è meglio se lo fai direttamente tu? Io sicuramente faccio un casino... Ho ripiegato sulla cancellazione dell'unsigned perche' non ci stavo capendo niente...

jumpjack:
Si', ma questo è un compilatore per un affarino con 2k di RAM, pensavo che un minimo di controllo lo facesse...

Il problema delle variabili è che vengono allocate a runtime quindi a priori non puoi sapere quanto spazio occuperanno. Inoltre l'SRAM contiene anche lo stack e l'heap: se il tuo codice è molto iterativo, alla fine consumi un sacco di memoria per tener traccia dei salti. Poi immagina un array dinamico quale una stringa. Ti metti lì a fare Stringa.add() a non finire... Come può un compilatore controllare tutto questo? :slight_smile:
Dovresti avere un emulatore/simulatore per lanciare il codice e guardare cosa realmente succede.

Lesto, come stai messo? Hai fatto qualche prova? Io ho saldato i 3 fili al mio povero 6600 che ormai sembra piu' un rottame che un telefono, tante le volte che l'ho aperto...
Riusciamo a mandare 'sto SMS? :slight_smile:

Ho messo il sorgente in condivisione col mondo, per lavorarci tutti insieme:

sto che devo fare ancora tutto.. :slight_smile:

Ottimo, siamo un pezzo avanti.
Vabbe', io attacco la Arduino, al massimo esplode lei e il cellulare. :slight_smile:

guarda che ho provato ora a compilare, il sendmsg in unsigned char non mi da problemi...

lesto:
guarda che ho provato ora a compilare, il sendmsg in unsigned char non mi da problemi...

Boh.. meglio.
Io invece ho attaccato la Arduino al cell, e...

non succede niente!
Il cellulare non me se fila proprio!

Mi pareva troppo bello...

Come posso fare a lasciare libera la seriale/USB per stampare un po' di mex di debug senza che interferiscano con la trasmissione FBUS? Con Softserial? E' questa la libreria per impostare due pin qualunque come seriale?