<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>As a side note:</p>
<p>you can of course design your own little protocol. Just be
careful with something like this:</p>
<p>[length, data1, data2, ..., length, data1, data2, ...]</p>
<p>For this to work you need to know the start of the transmission
and you can't recover from data loss because when you start
parsing from a random position, you don't know what each byte
actually means.</p>
<p>So it is generally safer to either choose one byte as a delimiter
(probably with some kind of escape mechanism, like SLIP does) or
reserve certain bytes as status bytes (like MIDI does). This way
you can start listening to an already running stream of data and
know exactly where a new packet begins.</p>
<p>---<br>
</p>
<p>Of course you can just send/receive the data as ASCII, where the
delimiter probably would be \0 or \n. <br>
</p>
<p>If you only send data *from* the Arduino to Pd, you can easily
use FUDI (Pd messages):</p>
<p>Serial.print("foo 1 2 3; bar 1 2 3;\n");</p>
<p>In Pd you just need to collect bytes to till you reach a newline
(\n) and then send the resulting list of bytes to [fudiparse] and
it will output the messages [foo 1 2 3( and [bar 1 2 3(.<br>
</p>
<p>Christof</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 01.02.2020 01:11, Christof Ressi
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:daa0f6f0-dd2c-21e9-44df-b9d5e86dc043@christofressi.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<p>Hi,<br>
</p>
<blockquote type="cite">How do I get Arduino to send the complete
values as integers instead?</blockquote>
<blockquote type="cite">And, how can I tell [pd] when a new data
set of e.g. six values begins?</blockquote>
Short answer: you need a protocol. Someone already mentioned SLIP.
For Pd there is an external called [mrpeach/slipenc] resp.
[mrpeach/slipdec] and for Arduino there are libraries like <a
class="moz-txt-link-freetext"
href="https://github.com/bakercp/PacketSerial"
moz-do-not-send="true">https://github.com/bakercp/PacketSerial</a>
or <a class="moz-txt-link-freetext"
href="https://github.com/CNMAT/OSC" moz-do-not-send="true">https://github.com/CNMAT/OSC</a>
(see SLIPEncodedSerial.h).<br>
<p>Please read the following to understand the problem which SLIP
and similar protocols are trying to solve: <a
class="moz-txt-link-freetext"
href="https://github.com/bakercp/PacketSerial/blob/master/docs/BACKGROUND.md"
moz-do-not-send="true">https://github.com/bakercp/PacketSerial/blob/master/docs/BACKGROUND.md</a></p>
<p>It doesn't have to be SLIP, though. You can use any
encoding/protocol you like as long as both sides agree :-) I've
even (ab)used MIDI because it is quite compact and rather easy
to parse.<br>
</p>
<p>Christof<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 31.01.2020 23:18, Dr. Maik Hester
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:0d6b2603-eb70-a802-200b-47a7c88289fc@gmx.de">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<p><br>
</p>
<div class="moz-forward-container"><br>
<br>
-------- Weitergeleitete Nachricht --------
<table class="moz-email-headers-table" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Betreff:
</th>
<td>Re: [PD] sending lists via [comport]</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Datum:
</th>
<td>Fri, 31 Jan 2020 22:34:24 +0100</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Von:
</th>
<td>Dr. Maik Hester <a class="moz-txt-link-rfc2396E"
href="mailto:maik.hester@gmx.de"
moz-do-not-send="true"><maik.hester@gmx.de></a></td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">An:
</th>
<td>hans w. koch <a class="moz-txt-link-rfc2396E"
href="mailto:hansw.koch@gmail.com"
moz-do-not-send="true"><hansw.koch@gmail.com></a></td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Kopie
(CC): </th>
<td><a class="moz-txt-link-abbreviated"
href="mailto:pd-list@lists.iem.at"
moz-do-not-send="true">pd-list@lists.iem.at</a> <a
class="moz-txt-link-rfc2396E"
href="mailto:pd-list@mail.iem.at"
moz-do-not-send="true"><pd-list@mail.iem.at></a></td>
</tr>
</tbody>
</table>
<br>
<br>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<p>Dear list,</p>
<p>the logic in the attached patch works fine, but I am still
stuck at two different points:<br>
</p>
<p>The Arduino sends each digit of the values as a two-digit
ascii. How do I get Arduino to send the complete values as
integers instead?</p>
<p>And, how can I tell [pd] when a new data set of e.g. six
values begins?</p>
<p>Thanks<br>
Maik</p>
<p><br>
</p>
<div class="moz-cite-prefix">Am 29.01.20 um 00:00 schrieb hans
w. koch:<br>
</div>
<blockquote type="cite"
cite="mid:037C3FB2-83DC-467E-922F-5D5206928F9E@gmail.com">
<pre class="moz-quote-pre" wrap="">if the incoming data all have the same structure (i.e. the strings of numbers have the same lenght),
you could group them in lists and then use unpack to sort their destinations.
like in the patch attached
hth
hans
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Am 28.01.2020 um 23:25 schrieb Dr. Maik Hester <a class="moz-txt-link-rfc2396E" href="mailto:maik.hester@gmx.de" moz-do-not-send="true"><maik.hester@gmx.de></a>:
Dear list,
does anyone know how to send the different values of each line from the
sample below to [comport] as a list, strip this list in [pd] and route
the values to their different destinations?
The data comes via Arduino from a pixy cam.
Here is a sample from Arduino's serial monitor:
Detected 6
block 0: sig: 2 x: 273 y: 36 width: 42 height: 5 index: 41 age: 18
block 1: sig: 1 x: 272 y: 187 width: 36 height: 4 index: 37 age: 18
block 2: sig: 1 x: 266 y: 151 width: 28 height: 4 index: 226 age: 71
block 3: sig: 1 x: 274 y: 109 width: 20 height: 4 index: 155 age: 124
block 4: sig: 2 x: 280 y: 48 width: 32 height: 2 index: 223 age: 72
block 5: sig: 1 x: 240 y: 136 width: 24 height: 2 index: 52 age: 5
At the moment [comport] receives all the numbers one after another (e.g.
2 273 36 42 5 41 18 ...), so that it is impossible for me to tell
[pd] which number should go where.
I kept checking the internet for a solution for several days which did
not bring me any further, so I hope that someone in the [pd] community
could give me a clou.
Thanks
Maik
--
__
Dr. Maik Hester
Musiker, Musikwissenschaftler, Akkordeon-Restaurator
Himmelohstraße 23
D-58454 Witten
_______________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:Pd-list@lists.iem.at" moz-do-not-send="true">Pd-list@lists.iem.at</a> mailing list
UNSUBSCRIBE and account-management -> <a class="moz-txt-link-freetext" href="https://lists.puredata.info/listinfo/pd-list" moz-do-not-send="true">https://lists.puredata.info/listinfo/pd-list</a>
</pre>
</blockquote>
</blockquote>
<pre class="moz-signature" cols="72">--
__
Dr. Maik Hester
Musiker, Musikwissenschaftler, Akkordeon-Restaurator
Himmelohstraße 23
D-58454 Witten</pre>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:Pd-list@lists.iem.at" moz-do-not-send="true">Pd-list@lists.iem.at</a> mailing list
UNSUBSCRIBE and account-management -> <a class="moz-txt-link-freetext" href="https://lists.puredata.info/listinfo/pd-list" moz-do-not-send="true">https://lists.puredata.info/listinfo/pd-list</a>
</pre>
</blockquote>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a> mailing list
UNSUBSCRIBE and account-management -> <a class="moz-txt-link-freetext" href="https://lists.puredata.info/listinfo/pd-list">https://lists.puredata.info/listinfo/pd-list</a>
</pre>
</blockquote>
</body>
</html>