Go Down

Topic: Secret to serial communication? (Read 781 times) previous topic - next topic

Graynomad

Quote
but I do need a big delay right after I open the /dev/ttyACM0 device

Because opening the port resets the Arduino and it takes a while for it to get up and running.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Claghorn

Well, that's annoying. You mean if I want to talk to this thing over USB, I have to hold the port open all the time or I'll reset it? Sure seems to be the case though. I changed my test to ask for the micros() value and send it back, and it is always about the same, so it sure looks like it is reset simply by opening the tty.

I wonder why avrdude has all sorts of code in it to diddle the RTS and DTR signals to do a reset? Maybe different hardware versions need that?

I guess it is just as well my long term plans are to use it over bluetooth :-).

Graynomad

#7
Apr 02, 2012, 02:43 am Last Edit: Apr 02, 2012, 02:45 am by Graynomad Reason: 1
The auto-reset is a good idea 98% of the time because it means you don't have to try and press the reset button at exactly the right moment every time you program the Arduino.

It does catch people doing what you are doing though.

The smart thing to have done with the design is put a jumper in so you can disable the feature at will, but Arduino tend not to think of such niceties. However many other people do and if you check out some of the clones they have fixed this issue.

You can also disable the reset feature by cutting a track, removing a cap, or adding a large cap, try searching the forum I'm sure there will be many threads about this with links to fixes.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Claghorn

I decided the thing to do is modify my microcode to send out a "I just got reset" message from setup(). Now when I open the device, I can send a bad command and wait and see if I get back an error message or a reset message. That let's me figure out when I can talk as soon as possible without putting in arbitrary large delays and works if I get reset (USB) or don't get reset (bluetooth). Should be handy for letting me know if the arduino got a power hit as well since I'll see a reset message when it comes up after that.

If I ever have any state I need saved, I'd better keep it in eeprom I guess.

In any case, this technique does seem to be working.

dewy721

Another option you could do is to add a 10 microfarad capacitor to the reset pin to keep the arduino from rebooting (unless you press and hold the button). That way your data flow would be as it would be over Bluetooth.

Go Up