Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

Da float a string in C

Raccolta di codici sorgenti

Moderatore: Foto UtentePaolino

0
voti

[21] Re: Da float a string in C

Messaggioda Foto UtenteDirtyDeeds » 30 lug 2013, 22:25

Ma questa fuffa che ricevi, in mezzo, ha anche i byte del valore oppure proprio non ci sono?

Per esempio, ricevi

12.3lwfjlkwfhjbmsdf,fn,dsf :?:

oppure

elkfngejbgejkgbfj :?:

En passant, la variabile status_device, siccome viene modificata da un interrupt, andrebbe dichiarata volatile.
It's a sin to write sin instead of \sin (Anonimo).
...'cos you know that cos ain't \cos, right?
You won't get a sexy tan if you write tan in lieu of \tan.
Take a log for a fireplace, but don't take log for \logarithm.
Avatar utente
Foto UtenteDirtyDeeds
55,9k 7 11 13
G.Master EY
G.Master EY
 
Messaggi: 7012
Iscritto il: 13 apr 2010, 16:13
Località: Somewhere in nowhere

0
voti

[22] Re: Da float a string in C

Messaggioda Foto Utentelcua31989 » 30 lug 2013, 22:30

il 12.3 non c'è. Ci sono solo: ˜’ŠÂ¹Âÿ
Avatar utente
Foto Utentelcua31989
58 1 1 7
Frequentatore
Frequentatore
 
Messaggi: 194
Iscritto il: 28 nov 2012, 23:37

0
voti

[23] Re: Da float a string in C

Messaggioda Foto UtenteDirtyDeeds » 30 lug 2013, 22:34

E sei sicuro che quella stringa arrivi proprio dal pezzo di codice finora incriminato?

Cosa succede se togli la parte di codice che modifica mex, lasciando il vettore al valore iniziale? Ricevi xx.x?
It's a sin to write sin instead of \sin (Anonimo).
...'cos you know that cos ain't \cos, right?
You won't get a sexy tan if you write tan in lieu of \tan.
Take a log for a fireplace, but don't take log for \logarithm.
Avatar utente
Foto UtenteDirtyDeeds
55,9k 7 11 13
G.Master EY
G.Master EY
 
Messaggi: 7012
Iscritto il: 13 apr 2010, 16:13
Località: Somewhere in nowhere

0
voti

[24] Re: Da float a string in C

Messaggioda Foto Utentelcua31989 » 30 lug 2013, 22:37

Ciao

sì ho provato e ricevo t=xx.x
Avatar utente
Foto Utentelcua31989
58 1 1 7
Frequentatore
Frequentatore
 
Messaggi: 194
Iscritto il: 28 nov 2012, 23:37

0
voti

[25] Re: Da float a string in C

Messaggioda Foto UtenteDirtyDeeds » 30 lug 2013, 22:42

Se modifichi così:

Codice: Seleziona tutto
case 5: //infosystem sms
              mex[0] = '0';
              Uart1_Write_Text(mex);


Cosa ricevi?
It's a sin to write sin instead of \sin (Anonimo).
...'cos you know that cos ain't \cos, right?
You won't get a sexy tan if you write tan in lieu of \tan.
Take a log for a fireplace, but don't take log for \logarithm.
Avatar utente
Foto UtenteDirtyDeeds
55,9k 7 11 13
G.Master EY
G.Master EY
 
Messaggi: 7012
Iscritto il: 13 apr 2010, 16:13
Località: Somewhere in nowhere

0
voti

[26] Re: Da float a string in C

Messaggioda Foto Utentelcua31989 » 30 lug 2013, 22:45

giustamente ottengo:

0=xx.x
Avatar utente
Foto Utentelcua31989
58 1 1 7
Frequentatore
Frequentatore
 
Messaggi: 194
Iscritto il: 28 nov 2012, 23:37

0
voti

[27] Re: Da float a string in C

Messaggioda Foto Utentelcua31989 » 30 lug 2013, 22:46

Ho scoperto cosa non piace:

temp_decimale = ((conv_temp)%10);

non capisco il percè però
Avatar utente
Foto Utentelcua31989
58 1 1 7
Frequentatore
Frequentatore
 
Messaggi: 194
Iscritto il: 28 nov 2012, 23:37

0
voti

[28] Re: Da float a string in C

Messaggioda Foto UtenteDirtyDeeds » 30 lug 2013, 23:14

Se guardi la stringa ricevuta come fuffa:

Codice: Seleziona tutto
˜’ŠÂ¹Âÿ


vedi che questa ha 7 caratteri, mentre la tua originale ne ha 6. Ciò significa che la stringa è stata corrotta e gli è anche stato rimosso il carattere nullo iniziale. Questa corruzione potrebbe arrivare da un'altra parte del programma, ma senza debugger, a distanza, non so cosa dire

sorry
It's a sin to write sin instead of \sin (Anonimo).
...'cos you know that cos ain't \cos, right?
You won't get a sexy tan if you write tan in lieu of \tan.
Take a log for a fireplace, but don't take log for \logarithm.
Avatar utente
Foto UtenteDirtyDeeds
55,9k 7 11 13
G.Master EY
G.Master EY
 
Messaggi: 7012
Iscritto il: 13 apr 2010, 16:13
Località: Somewhere in nowhere

Precedente

Torna a Firmware e programmazione

Chi c’è in linea

Visitano il forum: Nessuno e 16 ospiti