Unsupported — We cannot guarantee that this software will work properly on Mac OS 10.8 and above. Please be careful.

Release: Serial IO, v20080326

Release Type: Beta
Version: 20080326
Release Notes

This is a fairly polished serial io patch (both smokris and I have been hacking on it mercilessly for the past day or two for an upcoming project)

Input and Output has been varified with an Arduino Diecimila at a few different baud rates (9600, 38400) with success. Binary output works (was added several betas ago, didn't get personally tested by me till today ;).

However, as is the case with all things kineme, we've hit upon a pretty nasty driver bug with ftdi (not surprised). I'm working with one of their techs to resolve this issue, hopefully that'll be fruitful.

The problem is basically this: Opening the serial port but never reading from it eventually causes some buffer overflows in the kernel. This causes some annoying side effects if you don't catch it soon enough. So if you have a Serial Output patch in the composition, you should add a matching Serial Input patch (with a specified break string!), and send its output to some red patch (a zero-count iterator is a cheap data sink). This will cause it to read out the buffer, averting the potential overflow (which shouldn't happen anyway).

This is close to a production release; please hammer on it, and find any weird corner cases where it doesn't work as expected (breakstring-less input will stop at 1 million bytes, then it'll probably trigger the overflow as noted above. This is the only known misfeature presently).

PreviewAttachmentSize
SerialIOPatch-20080326.zip39.35 KB

franz's picture
carriage return

hi as you advice me, i still don't manage to set a carriage return as a breakstring. tryied /n /r /t but none seems to work...

cwright's picture
screenshot?

Can you take a picture of the inspector panel and maybe the output, as well as console logs? Everyone seems be be having entirely different issues with this patch, it's driving me insane (Alex Beim can't get it to send anything, we can't get it to read-only without kernel panicing, and you can't get breakstrings to work.... wtf is going on?)

yoki's picture
hmmmm..

i have started playing with this patch and the new Arduino Diecimila i got today.. :)

i am also having problems sending although i actually got it to work for a while (being able to use the interpolation patches with the arduino light-dimmer example, yay! :) ) i dont know what the exact circumstances was then but i was fiddling a lot sending test-stuff in the arduino-serial monitor and suddenly the send-buttons in the serial-patch just worked.. since then i havent been able to reproduce a working behaviour from the serial-out patch though.. :(

(small feature request it would be nice with some kind of output like a boolean from the serial-out patch to see if it was even able to open a serial connection successfully.. it is a very quiet patch now :) )

cwright's picture
success != success

part of the stupidity of the whole thing is that it'll open the device without any errors for reading and writing (so it'll appear successful) -- it only fails when actually sending data, where the driver returns the shockingly unhelpful "device or resource temporarily unavailable" error message... that's all we've got to work with here, and after a short volley of e-mails to FTDI's tech support department, they've stopped talking to me (I demonstrated this bug using their supplied code, they got pissed and asked for schematics, I provided all the arduino tech docs I could, and now they're ignoring me...)

So while I too would like the boolean to be there, there's not really a way for it to provide useful data until after it has already failed; not helpful :(

yoki's picture
hmm..

when i tried to access the arduino using processing (to see that it actually worked before i started messing with it in QC) processing also failed opening the device correct.. when i checked the processing www i discovered that that bug was due to some FTDI/Leopard-trouble which they fixed in version 134 (i was testing with 133) with the latest version of processing it all works great.. Maybe some clues to whats going on can be found in the processing forums / svn.. i'll browse around there and see what i can find :)

cwright's picture
Versions

If you could, please report what you find regarding version numbers for the ftdi drivers, and provide links to them; I've kept up with the latest drivers since last summer (through Tiger and Leopard), and have only started having success with the latest batch as of early march-ish, 2008. I've pointed others to the version I've got installed, but they still experience problems.

Getting to the bottom of this will probably add a few more years to my life (allowing me to make a few more fun plugins I guess ;)

yoki's picture
sorry

false alarm.. they are using a javalib called RXTX to handle the serial connection to arduino :/

cwright's picture
s'ok

that's ok, it gives some clues as to what to look at for reference, if nothing else. Thanks for the info! :)

dust's picture
/n

/n seems like it would be the c way to break a line or using the standard name space << endl;

i have been using println(); instead of print();seems to work, not sure if this what you guys are talking about. Serial.println(); seems to do a carriage return. i have been using it empty but i think if you go Serial.println("cereal2osc"); you don't need to use Serial.print("abc"); Serial.println(); to do a carriage return.

if you guys are referring to the break line, issue if reading an unconnected serial patch i got's no idea. most times im doing an infinite loop its cause i messed up some code. apparently when reading usb you want to be in that loop so your data is always being transmitted.

will report on sending to arduino 2009 from qtz when i get my built in usb fixed. kind of sucks brand new MBP and both usb have stopped working, the keys and isight are still up.

guess im going to plug in all my drives and stuff to my server and remote stuff back and forth. rrrrrrrrrrr.

volkerk's picture
break string?

i could not specify the break string successfully. the serial device returns the following:

126 0 0

126 0 0

126 0 0

126 0 0

looks like two carriage return. how do i define it in the patch?

thx, volker

cwright's picture
hmm...

Not sure if the current break string mechanism works with multi-character strings, but you could give that a shot ("\n\n" instead of just "\n"). If that doesn't work, please e-mail me personally -- Another user has also brought up some break-string-related problems, and these might be related issues.

franz's picture
2 !

i never got the breakstring to work correctly ... ! (i had to insert a flush() call in the arduino code to prevent flooding ) i'll try 2 carriage return as you cleverly pointed it out ! seems like it might work, as i do have the same output as you. thanks for coming with this !!!!

schnogg's picture
Sweet, break help

This is a sweet patch. I'm also having trouble with the break string. I need it to break with two carriage returns, but it only works when i give it \n. It does not work with \n\n. Any thoughts? Does the patch maybe require some delimiting character between the breaks? maybe it thinks that it is escaping to n\n rather than escaping to two newlines? I dunno.

schnogg's picture
k seconds later,

Replying to my own question, awesome! Basically i used od -t c to see that my serial device was spitting out \r\n\r\n as a line break, so I set the break string to that. Using od -t c /dev/cu.serialwhatever was pretty effective for me to find my break code.

cwright's picture
breaks

There are some strange issues with break string as far as I've heard -- I've not had much time to test, unfortunately, but if you'd like, e-mail me (info@kineme.net), and we'll discuss this issue to try to get it resolved.

waxtastic's picture
Output problems

The serial input works great. Here you can download an example that reads all of the analog input pins of Arduino to QC: http://originalhamsters.com/blog/2008/11/16/arduino-quartz-composer/

Adding digital input to this would be easy also, but I'm still trying to figure out the best way to do it.

I having a lot of problems with the output though. I can't seem to send anything out. Anyone have a working example of sending data to Arduino. I would like to get to the bottom of this and have all the outputs and inputs working from QC.

dust's picture
arduino

so i was helping a friend the other day hook up his pezzzo sensors to an arduino and was having a problem sending a boolean to max msp. apparently the arduino simple messaging or what ever was made 3 years ago. the example patches are way 2 over complicated for such a simple device. so i decided to get this plugin, and switch things to OSC. i flashed the arduino with the some c code. then connected the serial patch to an osc send, changed the send port to 9600 in OSC just to confuse my friend, viola no problems.

thought there might be some sort of issue with serial being a different bit rate than OSC or what ever but works like a charm as far as getting info off the analog pins. i like using OSC, i hope soon the soft synth developers realize OSC is the future, it just seems like more of a universal format than midi, seeing that the internet works with UPD. of course im a midi junky but find my self spending unneeded time converting OSC to midi cc messages. so needless to i like using quartz and kineme to translate things like wii or arduino/serial to OSC, with little effort.

so i was pleased with how simple it was to flash the micro-controller hook up a sensor convert serial to OSC. that i went out and ordered a new arduino. got the 2009, yesterday. so now im going to tinker with sending some info to it, apparently thats where people are running into trouble. unfortunately i get my arduino in the mail yesterday and the same day my USB decides to kick out. brand new mac book pro less than a month old, its weird the keyboard and i sight still works, wish i could open the thing. so it might be a week or 2 till i can comment on sending info.

gtoledo3's picture
This may be totally off

This may be totally off topic.. .or just a little bit but...

Memo's web cam piano with OSC setup is cool as heck... and EVEN cooler to hook it up to something like Garage Band, Logic, etc... and use it to trigger samples, or chain effects. Whereas, for me at least, what I get out of the stock setup wouldn't be so useful... you start triggering some distorted wurlitzer/rhodes/slide guitar samples, with lots of distortion, auto wah wah/ envelope filters, etc... and it actually sounds like a wild sound for "solo-ing".

This is making me realize I need to dig some of those projects out ... kind of left that one by the wayside.

dust's picture
memo osc web cam piano

most defiantly memo is doing some cool ass shit. i had made maybe 5 different web cam theremin, webcam vst, webcam rgb mean 2 vst, webcam light sensor potemento etc.. plus various tracking 2 synth stuff. but its hard me being into harmonically mixing stuff to get the rgb mean average 2 midi thing to sound good. i guess its just as hard as playing the actual theremin, i started making some versions that only put out the notes i wanted and in addition did some hidden markov chain probabilities based on the notes i was triggering so my computer could play along with me waving my hands in the air and flipping the light switch on and off. (my wife thinks im crazy by the way) she is classical pianist. and the fucking computer starts to play with me and apparently can in a few seconds of sorting out the anticipated note based on my markov chains was playing the piano better than i can. i mean i have been playing instruments my whole life and in a few seconds the computer is like this is how i play. ????

truly amazing to me in my world at least. so im thinking how i play . i pick some notes out and randomly play them in different octaves to make electro or what ever so i took that principle. and hooked up some markov chains randomly to garageband or what ever and this is what my computer comes up with. kind of pisses me off actually, i had to record this because the nature of random and stochastic music means it will never do the same performance twice, and in addition it dosent even play the same pattern twice in a performance, its your mid tricking you into hearing patterns in randomness.

http://cordova.asap.um.maine.edu/~oconnord/StochasticComposition.mp3

so back to memo, i decide to do a web search on web cam piano and memo pops up, im like wow this kid is working on CV multi touch quartz etc.. and explored his patch cause i haven previously till i upgraded to leopard to do optical flow stuff with quartz, and his web cam piano is pretty cool i must admit. it made me buy OSCulator which in turn has been my best friend with /mrmr 2 traktor pro or mainStage. so he seems to be on it with that patch utilizing scales and stuff so you can harmonically improvise with other people or computers.

i found my self using his patch instead of my own that i spent the last year perfecting. i like making electro music, utilizing arps and stuff so i found out that if you set the memo grid to lets 2 columns and 7 rows then put it on a chromatic pentatonic or something triggering arpegios and or baselines works much better. setting the grid 14X14 starts getting way to many notes and although in the same scale sometimes the polyphony harmonics just gets to messy for me so i use a 2X7 or 7X2 grid or what ever on one computer and on my other laptop i use 7X14 for more lead kind of stuff then set various various notes to trigger things like drum loops and stuff. i do however really like the arabic scale he included sounds pretty cool triggering real guitar, nexus, or acoustic legends. gives you kind of gypsy feel.

so i found the combination of two cameras and two different grid works pretty good as a virtual collaborator or what ever.

i thought i was going to be smart one day and make the voice recognition midi controller so i could use my hands to do more things. well i built but me in my ideas sometimes manifest but not the way i want them. like i want to manifest an elephant for a pet but i forget that an elephant has big shits. or getting married or whatever is the same analogy. anyways i built it and forgot that the i was making music controlled vis my voice 2 midi but the music inter-fears with the recognition part so it rendered that patch useless. unless i use headphones and the whole thing was made for performance. so it could work in a broadcast situation but thats just another controller or useless app that i will never use. so im excited today to see kineme voice recognition.

so what does this have to do with the arduino well that gets worked into to all the controllerism madness soon as the usb starts working i guess untill then i will have to use my ipod as controller in the mean time. thought about making a midi controller out of the arduino. apparently stanford has away of getting the arduiono to actually send OSC nativly but that requires a PC and kineme Serial2OSC works fine for me. although the machine learning class im taking at stanford has helped me learn a bit of code for voice seperation or back ground cancellation of of audio but it requires 2 mics. funny one of my teachers said it couldn't be done i take an online class and the guy shows us the first day with two lines of code ???

andrew is doing some pretty cool stuff, got to figure out matlab. check out one of his projects http://make3d.stanford.edu/ machine learning is changing everything.

jean_pierre's picture
Re: Release: Serial IO, v20080326

a few years later; while i can read over serial without issue, the serial output patch almost seems as if it does not properly initialize the serial buffer for writing. banging the send signal port does absolutely nothing, the ardiuno board's RX LED doesn't indicate any activity.

often, if i pop the serial monitor open in the arduino application, send a single pack of data to the arduino and close the serial monitor, then the send signal port comes alive!

is it possible that the output buffer isn't fully initialized? what are other's experiences with the serial output patch?

in case it matters, i have the latest FTDI drivers installed from arduino 22 on a duemilanove (with atmega328 upgrade). additionally, i double checked that the arduino sketch was ok by double checking in Max that i can read and write -- no problems. i'll be interested to see how the uno works which does not require the FTDI drivers…

2011 MacBook Pro / Mac OS X 10.6.7 / QC 4.0 (103.1) / Arduino 33 / Arduino Duemilanove + atmega328 / FTDIUSBSerialDriver 2.2.14

jean_pierre's picture
Re: Release: Serial IO, v20080326

just to update the thread; i am inclined to think this behavior is perhaps a defect of the serial output patch, i gave matti's MonsteriSerialOut patch a try (swapped it in place in my comp) and it worked without issue. so for those in a similar situation, definitely give that a look.

steve holmes's picture
Re: Release: Serial IO, v20080326

Where did you download the MonsteriSerialOut patch from? Cheers steve

jean_pierre's picture
Re: Release: Serial IO, v20080326

hi steve - the patch is in beta and i'm not sure it is intended for general consumption yet, but if you look in the feature requests / arduino thread, there is a comment from waxtastic where he links to it. like the kineme serial patch, it sounds as though one must pair a reader when writing to avoid a buffer overflow, though i cannot say for sure if this is still true with the latest FTDI drivers. matti's patch only allows one to transmit a single character right now, but this still provides quite a few values and i only needed to send a bang to the arduino, so the lack of more complex data transmission is a non-issue for me right now.

jean_pierre's picture
Re: Release: Serial IO, v20080326

no change in behavior with the FTDI-less Uno, i am still unable to write to a device. no bother though, matti's patch has gotten me up and running and i am now looking into my own simplified AMSerialPort-based device list/reader/writer QCPlugIns, cheers to vade for pointing me in that direction. oh and when i reported that i was using Arduino 33, i really meant 0022, sorry for the confusion.

Installation Instructions

Place the plugin file in
/Users/[you]/Library/Graphics/Quartz Composer Patches/
(Create the folder if it doesn't already exist.)

Source code is available on GitHub.