Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 9
61  Using Arduino / Microcontrollers / Re: Avrdude error with Leonardo ISP on: January 23, 2013, 04:34:27 pm
In what direction did you have to change the code to make it work?
In 1.0.3, it Should be if (USB_Available(CDC_RX)) or you have an infinite loop. I checked github, the change was comitted. I also just extracted arduino-1.0.3-linux32.tgz again and USBCore.cpp also contains  if (USB_Available(CDC_RX)).
62  Products / Arduino Due / Data loss when sending to native USB port (SerialUSB) on: January 20, 2013, 03:10:38 pm
I noticed that when sending 64 or more bytes from a pc to the Due's native USB port, bytes get lost.
This sketch reproduces it:

static const int led = 13;

void setup() {
  // initialize serial:
  pinMode(led, OUTPUT);     

void loop() {
  // if there's any serial available, read it:
  int i = 0;
  while (SerialUSB.available() > 0) {;
  digitalWrite(led, HIGH);
  digitalWrite(led, LOW);

If you send say 80 bytes to the serial port (e.g. simply via an echo to /dev/ttyACM1), the sketch prints series of numbers like this : 0 0 0 63 0 0, which indicates that (at least) 17 bytes are lost.

It can easily be fixed in CDC.cpp: the code defines a ring buffer of size CDC_SERIAL_BUFFER_SIZE (==512). But the code that uses it uses the SERIAL_BUFFER_SIZE macro which is 64. So replacing SERIAL_BUFFER_SIZE with CDC_SERIAL_BUFFER_SIZE in CDC.cpp fixed the problem for me (I wanted to run ArduinoISP which requires receiving 128 byte messages from avrdude).

It will go wrong if you feed the due more than 511 bytes at once. Therefore it would be better to use USB's built in handshaking mechanism (make the device reply with NAK or NYET until it has room to store more incoming data). The same was done for the Leonardo. I could look into how to do that with the due's otg controller, but if someone already knows, that would save time...

63  Using Arduino / Installation & Troubleshooting / Re: Micro not sending serial data on: January 04, 2013, 02:43:31 pm
I think the vb program does not set the (virtual) DTR signal for the serial port.
Try setting the port's DtrEnable property to True.
64  Using Arduino / Microcontrollers / Re: Weird issue: Micro won't transmit win8 on: December 29, 2012, 06:28:23 pm
...but if I run the ASCIItable sketch I do not see anything in the serial monitor.
I can repeat the behavior on a leonardo with windows 7 SP1, with linux it works correctly.

I know what happens. After you download the sketch, the IDE touches the serial port to remove the magic baudrate. Touching means it briefly opens the sketch's serial port. As a result, the "while (!Serial);" loop exits and the sketch wants to start sending characters. But the port is closed again briefly after this and your characters get lost.

As a work around you can reset the board with the reset button, after this the while (!Serial); loop has the desired effect and chars end up in the serial monitor.

Another work around (though kludgy) is this:

while (!Serial);  // <-- detects the touch
while (!Serial);  // <-- waits for the real port opening

Btw. It was me who proposed to touch the port after uploading, maybe it should be rolled back.

65  Using Arduino / Installation & Troubleshooting / Re: Leonardo won't initiate serial communication on: December 28, 2012, 05:54:30 pm
I just tried out serial comms between processing and the leonardo, myself. On the pc I did not need to do anything special to set DTR/RTS, so apparently processing (or the underlying rxtx) does this for you.

I have a better test sketch (for the leo/micro):
static const int led = 13;
unsigned char x;

void setup() {
  Serial.begin(9600); // Start serial communication at 9600 bps
  pinMode(led, OUTPUT);
  digitalWrite(led, Serial ? HIGH : LOW);

void loop() {
  Serial.write(x & 1);
  digitalWrite(led, Serial ? HIGH : LOW); 
It alternately sends out 0 and 1. Also, via the arduino led, it lets you observe DTR/RTS: Serial (or rather Serial's boolean operator) returns true when either DTR or RTS are high.

Run this sketch on the leo.
As long as the PC does not open the comm port, the leo's (or micro's) arduino led and the tx led remain dark. The leo runs its loop but all written bytes are dropped by the core.

Then, on the PC, fire up the standard processing example Libraries>serial>SimpleRead.
The arduino led lights up and the tx led flashes.
(and SimpleRead alternately shows a gray or black rectangle).

Note the behavior is different if you run the sketch on an Uno or Due (programming port). For these boards the tx led keeps flashing even if SimpleRead does not run (port not opened by the pc). (though I find that the leo's behavior is ok in this situation).

I tried this on linux 3.0.0-12 (kubuntu) and on windows 7 SP1. On windows I had to dowload the 32 bit version of processing because Serial does not run in 64 bit mode.

Could try whether this basic setup works for you?
66  Using Arduino / Installation & Troubleshooting / Re: Leonardo won't initiate serial communication on: December 27, 2012, 03:53:52 pm
I am looking at the pin diagram right now, I do not see DTR or RTS pins... I see RST on the board, but cannot make it which pin it actually is.

You are using the leonardo's virtual com port, so DTR and RTS are no real pins. The pc can however send control messages to "set" or "clear" these "virtual" DTR and RTS signals. And the leonardo's core will only send out data if DTR or RTS are set by the pc.
I am trying to get Analog input into Processing.
So you're processing app should set DTR/RTS. I don't know whether the Processing framework does this for you or how you can do this yourself.

Maybe it is best that you first try to run a simple app that sends out some  serial data and see whether you can receive the bytes from the Arduino-1.0.3 serial monitor. Maybe use wmassano's sketch:,137032.0.html
67  Using Arduino / Installation & Troubleshooting / Re: Leonardo won't initiate serial communication on: December 25, 2012, 05:24:44 pm
The leonardo only sends out data if the program/os on the pc sets either DTR or RTS, (or both) high. If you use a program like putty or the serial monitor in the IDE to communicate with the leonardo, there is no problem because these programs set DTR and/or RTS. If you do serial communications from your own program you must make sure yourself to set DTR/RTS.

I have been trying for 4 days now with no lunck.

Can you tell us more about what you try to accomplish? And on which os, version, sp...?
You may observe the same problem as what is described in this thread but it might be something completely different as well.

68  Using Arduino / Installation & Troubleshooting / Re: Leonardo doesn't talk to serial monitor in windows 7 on: December 14, 2012, 06:12:08 pm
That is great information, Paul. In my opinion, it should be added to the documentation (the minimum SP for windows, the minimum os version for mac). A classic arduino probably works on almost every windows version, for the leonardo, this appears not to be the case.

So the right thing to do for me would be to get SP3. But I should have done that a couple of years ago, now it may not be worth the effort and the risk that this old pc does not survive the upgrade. On the other hand that pc still works well and hapilly deals with my duemilanove, pic18F4550 (also cdc/acm) and the leo's bootloader.

So I thought my Leonardo sketches should work as well if I ran them as "serial only" usb devices (non composite, so no iad needed).

The code allows to do this with only a few ifdefs:
in USBDesc.h:
//#define HID_ENABLED
#if defined HID_ENABLED && defined CDC_ENABLED

in USBCore.h:

        IADDescriptor                           iad;    // Only needed on compound device

in CDC.cpp:

const CDCDescriptor _cdcInterface =

I compiled the sketch again and made a .inf file by copying the UNO's in file and adjusting the PID. This made the sketch run on the old xp sp2 box. I also managed to burn hex files via ArduinoISP into an attiny on the same pc.

I hope this does not sound like cursing to the developers who have put lots of effort to make composite devices work. But I believe this idea makes sense:
  • it is simpler.
  • because of this, it does work on all these old os'es without ugly hacks or spec violations.
  • in many occasions you only need either one of the interfaces, not both.
  • you win about 1K code size (dropping hid support).

Thanks a lot for sharing this. I started to investigate the problem but could not make sense of it. Windows installed the driver without error but the resulting behavior was really weird.

69  Using Arduino / Installation & Troubleshooting / Re: Leonardo doesn't talk to serial monitor in windows 7 on: December 12, 2012, 06:49:00 pm
@wmassano: on your win 7 it does not talk to the serial monitor, but does it blink?
70  Using Arduino / Installation & Troubleshooting / Re: Leonardo doesn't talk to serial monitor in windows 7 on: December 12, 2012, 05:37:35 pm
Believe it or not: I observe exactly the opposite: your sketch runs fine on my windows 7 sp1  but it does not work on win xp pro sp 2!

 I am also investigating problems related to the leonardo's virtual comm port in combination with windows (on linux, the leonardo works great). See here,118090.15.html. This is really driving me crazy.
71  Using Arduino / Microcontrollers / Re: Leonardo as ISP for ATtiny85 on: December 11, 2012, 04:57:57 pm
@kduin: what windows are you on? I hope it is not xp, I just discovered some problems with it.

The output you posted shows that the ide uses -cstk500v1. It should use -carduino instead (a work around, needed on windows). See,108270.msg1014458.html#msg1014458 for how to do this.
72  Using Arduino / Microcontrollers / Re: How to program ATtiny45 with Arduino Leonardo as ISP on: December 11, 2012, 04:31:20 pm
Well, since johntech2011 is on windows xp, I tried things out on that os (I used win xp pro sp2). Guess what, it did not work. The work around so use -c arduino (,108270.msg1013258.html#msg1) does not help either.

More in general communication over the leo's virtual com port does not work at all: error writing to serial port (tried putty, ide's serial monitor and avrdude) This is strange  since uploadng sketches to the leo's bootloader does work correctly. So this must be caused by the leo's core which works very well with linux but really has some problems with windows.

I want to figure this out but it does not look very good. All ideas are welcome.

73  Using Arduino / Microcontrollers / Re: Burning a Atmega 328 Bootloader with an Arduino Leonardo on: November 29, 2012, 05:50:28 pm
Thanks a lot RoystonS!

Now we know that -c arduino works and -c stk500v1 it is easy to figure out what goes wrong. The answer is in CDC.cpp:
size_t Serial_::write(uint8_t c)
        /* only try to send bytes if the high-level CDC connection itself
         is open (not just the pipe) - the OS should set lineState when the port
         is opened and clear lineState when the port is closed.
         bytes sent before the user opens the connection or after
         the connection is closed are lost - just like with a UART. */

        // TODO - ZE - check behavior on different OSes and test what happens if an
        // open connection isn't broken cleanly (cable is yanked out, host dies
        // or locks up, or host virtual serial port hangs)
        if (_usbLineInfo.lineState > 0) {
                int r = USB_Send(CDC_TX,&c,1);


(The TODO says it all...)
The two lsb bits of lineState correspond to DTR and RTS. Apparently on windows, DTR and RTS are not set, and the Leonardo will refuse to send out anything under these conditions.

I checked in avrdude, the code on linux and mac is the same, it does not do anything special to set RTS/DTR, so apparently the os does that. The windows code uses the win32 api, does nothing special either, but windows does not seem to set the signals.

Why does -c arduino work? Because for this protocol, avrdude explictly drops the signals for 250 ms to discharge the autoreset capacitor! Then it explicitly sets them back high! As a consequence this works also on windows with the Leonardo.

I don't know if we miss functionality when using arduino instead of stk500v1: to check...

I updated my writeup with this info. I am afraid Fulg is not the only one at all. Lots of people must have tried this and have been disappointed it did not work :-(.
74  Using Arduino / Microcontrollers / Re: Burning a Atmega 328 Bootloader with an Arduino Leonardo on: November 27, 2012, 05:20:34 pm
I can repeat the problem over here on a windows pc.
Will look at it tomorrow or so.
75  Using Arduino / Microcontrollers / Re: Burning a Atmega 328 Bootloader with an Arduino Leonardo on: November 27, 2012, 05:12:17 pm
Ok, but this is a leonardo, it should not autoreset. The only reason for autoreset I can see here is if the baudrate is set to 1200 in device manager > comm ports.
Pages: 1 ... 3 4 [5] 6 7 ... 9