[PD] error: unpack type mismatch

Alexandros Drymonitis adrcki at gmail.com
Tue May 19 22:29:49 CEST 2015


If the Arduino code uses Serial.println instead of Serial.write,then yes,
you are receiving ASCII.
If this is the case, try sending one value only and read it with the
attached abstraction, which is made to work with Serial.println.
If you want to transfer many values which are tagged with some string, use
[serial_println2] (it requires [bytes2any] from the moocow library).

On Tue, May 19, 2015 at 11:11 PM, Pagano, Patrick <pat at digitalworlds.ufl.edu
> wrote:

>  ​I'm using the arduino2pd patch hans created
>
> i understand what the error is i am hunting the object that will do the
> adjustment. I will try your suggestion but i think what is popping out is
> ascii numbers from comport which is reading pot values from 0-1023 the
> unpack says it's unpack floats but the number box which i assume should be
> able to deal with floats seems to only be reading ints maybe if i just
> multply x 0.01?
>
>
>
>   *Patrick Pagano B.S, M.F.A*
> Audio and Projection Design Faculty
> Digital Worlds Institute
> University of Florida, USA
> (352)294-2020
>   ------------------------------
> *From:* Alexandros Drymonitis <adrcki at gmail.com>
> *Sent:* Tuesday, May 19, 2015 3:46 PM
> *To:* Pagano, Patrick
> *Cc:* pd-list at iem.at
> *Subject:* Re: [PD] error: unpack type mismatch
>
>   but ASCII is just bytes, so subtracting 48 should do the ASCII to float
> job, right?
>  How are you sending values from Arduino to Pd? Do you use Serial.write or
> Serial.println? use [print] before you send stuff to [unpack] to see what
> you get. A type mismatch is when you expect a float but you get a symbol,
> for example.
>
> On Tue, May 19, 2015 at 10:08 PM, Pagano, Patrick <
> pat at digitalworlds.ufl.edu> wrote:
>
>>  hello
>>
>>
>>  i am working with arduino and raspi with comport spiiting out values
>> from pots attached to the arduino board and i keep getting the endless
>> warnings of
>>
>> error: unpack type mismatch
>>
>> error: unpack type mismatch
>>
>> error: unpack type mismatch​
>>
>>
>>  is there a way to remedy this? i looked around and i heard some people
>> talking about "atof" which i assume is ascii to float.
>>
>> But i cannot find it anywhere. I thought it was in zexy but maybe i have
>> the wrong name or perhaps i am off the mark entirely
>>
>>
>>  can someone help me out?
>>
>>
>>  pp
>>
>>
>>   *Patrick Pagano B.S, M.F.A*
>> Audio and Projection Design Faculty
>> Digital Worlds Institute
>> University of Florida, USA
>> (352)294-2020
>>
>> _______________________________________________
>> Pd-list at lists.iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> http://lists.puredata.info/listinfo/pd-list
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20150519/c9e2e91e/attachment.html>
-------------- next part --------------
#N canvas 390 157 570 389 10;
#X obj 50 15 inlet;
#X obj 146 135 t f b;
#X obj 146 199 +;
#X obj 173 160 f;
#X obj 173 182 * 10;
#X msg 188 129 0;
#X obj 146 221 t f f;
#X obj 50 238 f;
#X obj 50 112 t b b;
#X obj 50 260 outlet;
#X obj 50 37 sel 10 13;
#X text 142 7 to be used with [comport] for utilising Arduino's Serial.println()
function;
#X obj 146 106 - 48;
#X text 176 201 this is taken from the code often used in the Arduino:
;
#X text 198 219 while(Serial.available));
#X text 206 234 byte inByte = Serial.read() \;;
#X text 206 247 if((inByte >= '0') && (inByte <= '9'));
#X text 198 285 (curly brackets are not available in Pd's comments)
;
#X text 225 263 int temp = temp * 10 + inByte - '0' \;;
#X text 204 335 written by Alexandros Drymonitis;
#X obj 101 63 moses 48;
#X obj 146 85 moses 58;
#X text 162 62 let only digits through;
#X connect 0 0 10 0;
#X connect 1 0 2 0;
#X connect 1 1 3 0;
#X connect 2 0 6 0;
#X connect 3 0 4 0;
#X connect 4 0 2 1;
#X connect 5 0 3 1;
#X connect 6 0 7 1;
#X connect 6 1 3 1;
#X connect 7 0 9 0;
#X connect 8 0 7 0;
#X connect 8 1 5 0;
#X connect 10 0 8 0;
#X connect 10 2 20 0;
#X connect 12 0 1 0;
#X connect 20 1 21 0;
#X connect 21 0 12 0;
-------------- next part --------------
#N canvas 93 82 1049 470 10;
#X msg 76 182 583 54 909 223 4;
#X obj 76 244 serial_parseInt;
#X obj 76 376 comport 6 9600;
#X obj 76 398 serial_println;
#X obj 76 420 print;
#X msg 100 205 7829 87 5672 981;
#X msg 103 349 close;
#X msg 103 273 devices;
#X floatatom 103 303 5 0 0 0 - - -, f 5;
#X msg 103 322 open \$1;
#X text 218 181 send any number list to Arduino \, using the Serial.parseInt()
function;
#X obj 63 21 cnv 15 400 60 empty empty empty 20 12 0 14 -200075 -66577
0;
#X text 651 391 Made by Alexandros Drymonitis;
#X text 634 57 [serial_parseInt];
#X text 636 75 Arguments: none;
#X text 636 91 Inlet: number list;
#X text 636 107 Outlet: provided list encoded so that Arduino's Serial.parseInt()
function can understand it;
#X text 634 177 [serial_println];
#X text 636 194 Arguments: none;
#X text 636 208 Inlet: raw data received from Arduino (through [comport])
\, using the Serial.println() function;
#X text 74 28 [serial_parseInt] and [serial_println]: absrtactions
to work with the Serial.parseInt() and Serial.println() functions of
Arduino \, respectively*;
#X text 74 85 *[serial_println] won't work with Serial.print() \, but
only with Serial.println();
#X text 74 125 This help patch is used with the parseInt_println.ino
Arduino sketch;
#X text 178 398 receive numbers from Arduino via the Serial.println()
function;
#X text 636 237 Outlet: data received from Arduino with the Serial.println()
function \, assembled to numbers;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 5 0 1 0;
#X connect 6 0 2 0;
#X connect 7 0 2 0;
#X connect 8 0 9 0;
#X connect 9 0 2 0;
-------------- next part --------------
#N canvas 390 157 572 445 10;
#X obj 50 15 inlet;
#X obj 146 185 t f b;
#X obj 146 249 +;
#X obj 173 210 f;
#X obj 173 232 * 10;
#X msg 188 179 0;
#X obj 146 271 t f f;
#X obj 50 288 f;
#X obj 50 364 outlet;
#X obj 50 37 sel 10 13;
#X text 142 7 to be used with [comport] for utilising Arduino's Serial.println()
function;
#X obj 146 106 - 48;
#X text 176 251 this is taken from the code often used in the Arduino:
;
#X text 198 269 while(Serial.available));
#X text 206 284 byte inByte = Serial.read() \;;
#X text 206 297 if((inByte >= '0') && (inByte <= '9'));
#X text 198 335 (curly brackets are not available in Pd's comments)
;
#X text 225 313 int temp = temp * 10 + inByte - '0' \;;
#X text 204 385 written by Alexandros Drymonitis;
#X obj 101 63 moses 48;
#X obj 146 85 moses 58;
#X text 162 62 let only digits through;
#N canvas 511 98 458 417 strings 0;
#X obj 102 96 inlet;
#X obj 102 118 moses 65;
#X obj 147 141 moses 91;
#X obj 192 164 moses 97;
#X obj 237 187 moses 123;
#X text 164 119 A-Z;
#X text 254 165 a-z;
#X obj 147 266 t l l;
#X obj 126 289 list;
#X obj 147 244 list prepend;
#X obj 17 185 inlet print;
#X obj 126 361 outlet;
#X obj 17 232 spigot;
#X obj 17 257 t b b b;
#X msg 50 210 0;
#X obj 330 191 inlet reset;
#X msg 330 215 1;
#X obj 126 311 bytes2any;
#X obj 126 333 symbol;
#X connect 0 0 1 0;
#X connect 1 1 2 0;
#X connect 2 0 9 0;
#X connect 2 1 3 0;
#X connect 3 1 4 0;
#X connect 4 0 9 0;
#X connect 7 0 8 1;
#X connect 7 1 9 1;
#X connect 8 0 17 0;
#X connect 9 0 7 0;
#X connect 10 0 12 0;
#X connect 12 0 13 0;
#X connect 13 0 8 0;
#X connect 13 1 9 1;
#X connect 13 2 14 0;
#X connect 14 0 12 1;
#X connect 15 0 16 0;
#X connect 16 0 12 1;
#X connect 17 0 18 0;
#X connect 18 0 11 0;
#X restore 173 151 pd strings;
#X obj 50 311 pack f s;
#X obj 146 128 t f b;
#X obj 50 162 t b b b;
#X msg 50 333 \$2 \$1;
#X connect 0 0 9 0;
#X connect 1 0 2 0;
#X connect 1 1 3 0;
#X connect 2 0 6 0;
#X connect 3 0 4 0;
#X connect 4 0 2 1;
#X connect 5 0 3 1;
#X connect 6 0 7 1;
#X connect 6 1 3 1;
#X connect 7 0 23 0;
#X connect 9 0 25 0;
#X connect 9 2 19 0;
#X connect 11 0 24 0;
#X connect 19 1 20 0;
#X connect 20 0 11 0;
#X connect 20 1 22 1;
#X connect 22 0 23 1;
#X connect 23 0 26 0;
#X connect 24 0 1 0;
#X connect 24 1 22 0;
#X connect 25 0 7 0;
#X connect 25 1 22 2;
#X connect 25 2 5 0;
#X connect 26 0 8 0;
-------------- next part --------------
#N canvas 93 82 1048 569 10;
#X obj 76 264 serial_parseInt;
#X obj 76 396 comport 6 9600;
#X msg 100 225 7829 87 5672 981;
#X msg 103 369 close;
#X msg 103 293 devices;
#X floatatom 103 323 5 0 0 0 - - -, f 5;
#X msg 103 342 open \$1;
#X obj 63 21 cnv 15 400 60 empty empty empty 20 12 0 14 -200075 -66577
0;
#X text 626 144 Made by Alexandros Drymonitis;
#X text 624 55 Arguments: none;
#X obj 76 418 serial_println2;
#X floatatom 76 496 5 0 0 0 - - -, f 5;
#X floatatom 119 496 5 0 0 0 - - -, f 5;
#X floatatom 163 496 5 0 0 0 - - -, f 5;
#X floatatom 207 496 5 0 0 0 - - -, f 5;
#X floatatom 251 496 5 0 0 0 - - -, f 5;
#X msg 76 202 583 54 909 223 5;
#X text 74 32 [serial_println2]: absrtaction that works with the Serial.print()
and Serial.println() functions of Arduino;
#X text 624 69 Inlet: raw data received from Arduino (through [comport])
\, using the Serial.print() and Serial.println() functions;
#X text 624 100 Outlet: strings and numbers received from Arduino;
#X obj 76 471 route first second third fourth fifth;
#X text 178 408 receive pairs of strings and numbers from Arduino and
diffuse the numbers according to their corresponding strings. Works
like Python's dictionaries;
#X text 74 156 This help patch is used with the println2.ino Arduino
sketch;
#X text 73 90 In order for [serial_println2] to work \, you need to
send first a string which will be used as a key to diffuse the value
\, and then the actual value (see println2.ino for details). This abstraction
uses moocow's [bytes2any];
#X text 218 201 send any number list to Arduino \, using the Serial.parseInt()
function (though this seems to be a little bit slow);
#X text 307 471 receiving values from sensors responds faster than
the combination of this help patch and its Arduino sketch \, I guess
because of Serial.parseInt() \, but still I'm not sure;
#X connect 0 0 1 0;
#X connect 1 0 10 0;
#X connect 2 0 0 0;
#X connect 3 0 1 0;
#X connect 4 0 1 0;
#X connect 5 0 6 0;
#X connect 6 0 1 0;
#X connect 10 0 20 0;
#X connect 16 0 0 0;
#X connect 20 0 11 0;
#X connect 20 1 12 0;
#X connect 20 2 13 0;
#X connect 20 3 14 0;
#X connect 20 4 15 0;


More information about the Pd-list mailing list