Hi,
I am programming a C# interface for one of my Arduino projects which controls a machine.
I capture the messages back from the Arduino when I send a command.
The funny think is that I get also messages that have not been requested with the usual serial.write.
These back messages, common to all commands I send, looks like a confirmation back from Arduino. The messages look like these:
VMDPE_3|131_VMDPE (here I sent to Arduino a command to setup the PWM on analog 3 to 131)
VMDPE_3|0_VMDPE (here I sent to Arduino a command to setup the PWM on analog 3 to 0)
VMDPE_4|255_VMDPE (here I sent to Arduino a command to setup the PWM on analog 5 to 255)
VMDPE_4|0_VMDPE (here I sent to Arduino a command to setup the PWM on analog 5 to 0)
VMDPE_7|1_VMDPE (here I sent a command to setup pin 2 HIGH)
VMDPE_6|0_VMDPE (here I sent a command to setup pin 2 LOW)
VMDPE_5|1_VMDPE (here I sent a command to setup pin 13 HIGH)
VMDPE_8|0_VMDPE (here I sent a command to setup pin 13 LOW)
Now, looking at the above messages, I see that only in the case relevant the command sent to analog 3 the message is directly related to the pin that received the command. In all the other cases, and this is a mystery for me, there is apparently no link between the received message and the command I sent even if the Arduino is acting correctly as per command (I got that pin doing what I asked).
Is anyone of you able to give me some comment on the above?
And, what is the meaning of the VMPDE?
I think that once I have understood what is going on with these message, I can implement or use the Arduino better.
I don't see your bug yet, unless you send more than 10 characters between angle brackets.
But there is a bug in such a case: if you send more than 9 characters you'll overflow the inData buffer and overwrite index, which is the sort of thing that can lead to the weird behavior you're seeing.
It's best to check to see if there's room in a buffer before adding a character to it.
However, I have to check in my c# serial.read if something is appended in the message received from the Arduino but still I do not understand why there is a clear relation with the sent command only in the message related to analog 3!
VMDPE_3|131_VMDPE (here I sent to Arduino a command to setup the PWM on analog 3 to 131)
VMDPE_3|0_VMDPE (here I sent to Arduino a command to setup the PWM on analog 3 to 0)
All the other messages clearly report the status but to a pin that has nothing to do with the command!
ny idea?
PaulS,
sorry I forgot to confirm that the sketch I posted is the one that is sending back those message.
To avoid any misunderstanding between the sent message and the Arduino, I have also tested the same with the Arduino IDE directly.
In the attached image you see the Arduino sketch I posted,that is being loaded and the message sent with the serial monitor >100< that according to the sketch is supposed to setup PWM on analog 3 to 100
the message I get back from the Arduino is "VMDPE_3|100_VMDPE".
May be you can try my sketch on an Arduino UNO and confirm.
The sketch is the same.
The difference is in the IDE used to load it to Arduino.
In the pics I posted, the sketch was loaded using Visual Studio 2010 (Visual Micro plugin).
As you have seen even using the Arduino serial monitor (in that case I did not reload the sketch from the Arduino IDE), I got back those funny messages.
After your answers, in order not to appear like a puppy, I reloaded the sketch from the Arduino IDE and tested again........the messages have disappeared.
I need to investigate with the guys at Visual Micro. It looks quite obvious now that when the sketch is loaded from the VB10 plugin, something happen!
Thanks for your reply, actually forced me to do some more testing.
I finally understood what was going on.
I think is good to know for the future.
I write my code for Arduino and for my applications in C# using visual studio 2010 and two plugins:
Visual Micro
Visual Micro debugger http://www.visualmicro.com
To test the Arduino sketch with the debugger I use break points in the sketch. See this picture:
The sketch is then loaded to the Arduino and the debugger wait for the messages back to show the output.
I just realize now that those messages "VMDPE_3|131_VMDPE" are for the debugger.
This is the reason why after I loaded the sketch from the Arduino IDE the messages disappeared.
In this case there where no break points in the sketch. Those break points are only there in the Visual Studio IDE.
And this explain also why the messages are not related to the Arduino PIN but, instead, to the break point ID.
Answer explained here, you either need to build the project in Release (non-debug) mode or use a different dedicated Serial/SoftwareSerial port for debugging.
In summary, the debugger provides options to either share the main serial port (default) or use a dedicated serial port (or switch off debugging)