Insert char into array in embedded function
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tom
le 14 Avr 2018
Commenté : Walter Roberson
le 16 Avr 2018
Hello, I am trying to send array of data to arduino through Serial Send, however due to not knowing how large records will be ( each can range from 80 to 1000) I want to separate each data with coma in order to read them in arduino ( so I can go byte by byte and whenever there is a coma I will know that that record ends) . I tried inserting them in embedded function and casting result into uint8 but I am getting error about unknown output sizes. Is there any way to do it (or maybe better way to read array od data in arduino)?
function y = fcn(a,b,c,d,e)
q=[a,',',b,',',c,',',d,',',e,'|'];
y = typecast(q,uint8);
Thanks, Tom
2 commentaires
Walter Roberson
le 14 Avr 2018
As this is an embedded function, then your a b c d e must all be numeric. Are you sure you want to do the equivalent of char() of each of them as you build q? Or do you want to format them?
If I recall correctly, support for sprintf() was not added to Coder until R2018a; as far as I could tell in previous versions the work-around was to use coder.ceval() to invoke sprintf()
Réponse acceptée
Walter Roberson
le 15 Avr 2018
You would need to use coder.varsize() to declare the output string probably, and you would sprintf into it. If you are using before r2018a you might need to coder.ceval() to use sprintf.
You cannot just use char() on your values because you need to emit the printable equivalent of your values like '400' not char(400)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Arduino Hardware dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
