mathematica ruins serial interface???

Right now I have my arduino uno setup to serially print 64 numbers in a 16Lx4H configuration each separated by a "|" (The numbers are values from a temperature sensor). I also have the sketch wait for a serial input (the letter S) before outputting all the values. If i upload the sketch, open serial monitor, everything works fine. I type in "S" at the top of the serial monitor, send it, and I see my 64 values. If i input anything else, i get nothing as expected.

Now in mathematica (on a raspberry pi) I open the serial connection using this mathematica command:
serial = DeviceOpen["Serial", {"/dev/ttyACM1", "BaudRate" -> 9600}]. The baudrate is correct to what i have in void setup(). once it's connected, If i try to send the "S" through Mathematica's DeviceWriteBuffer command, the Arduino IDE Serial monitor will show a bunch of numbers with oddly placed decimals and "|"s. Also it is nowhere near 64 values, more like 20 characters total. If I go back to the Serial Monitor and try to send an "S" at the top, i get the same funky results. I've reset the arduino, closed and reopened the IDE/serial monitor, nothing changes. I still get weird values. If i try to reupload the same sketch, it will tell me there was a problem (avrdude : stk500_recv(): programmer is not responding). The only solution now is to disconnect the arduino and reconnect it physically, then i can reupload the same code.

This time I reuploaded the code, created the serial connection but did not send anything through mathematica. In the serial monitor, i tried to send an "S" and got the same weird output.

So sorry for the long read, but I have come to the conclusion that there is something going on with the serial interface when I set it up in Mathematica. I do not understand why because if i did a simpler program such as the one described here (Reading potentiometer values through your Arduino with your Raspberry Pi - Online Technical Discussion Groups—Wolfram Community) I never get weird values.

Does anybody know what is going on? Thanks

I don't know anything about Mathematica but I would be very surprised if it is necessary to re-upload the sketch to fix things. How could anything on the PC (except the Arduino IDE) alter the contents of the Arduino?

Try the following ...

Get your code working with the Serial Monitor - as you have already described
Try using Mathematica (I assume you will get the same wrong results)
Go back to the Serial monitor (also I assume wrong results).

Now for the new bits (all the time using the Serial Monitor)

Push the reset button on the Arduino - does that solve the problem ?
Restart the Arduino IDE - ?
Unplug and replug the Arduino - ?

Unplug the Arduino while the Serial Monitor is open and then replug it - which should cause the Arduino to appear on a different serial port - ?

Restart the PC - ?

I wonder if Mathematica may be adding a Carriage Return and / or Line feed after the 'S'. You can simulate that on the Serial Monitor by changing the line-ending box at the bottom of the Monitor screen to see if it causes problems. But I can't see why that would persist after Mathematica is stopped.

Have you a second PC that you could try the Arduino on without changing the Arduino code?

...R

Opening the Serial port in Mathematica can reset your Arduino (depends on how connected)

Can you post the Arduino part of your code?

robtillaart:
Opening the Serial port in Mathematica can reset your Arduino (depends on how connected)

That may screw up relations with Mathematica. But subsequently opening the Arduino Serial Monitor should cause another reset which should put things back to rights for working with the Serial Monitor.

...R

I know this reply is a little late but I have just gotten my serial communication working on my mac using the new "Device" communication functions in Mathematica 10. You don't say what type your numbers are. Have you tried sending a number that can be contained in one byte? Try sending Serial.print(x) where x is a number of type int between 0-255. In mathematica just use DeviceRead[devicename].