Log in

View Full Version : Serial Commands on MPLAB


tribotec_ca88
24-01-2006, 13:58
Just to check and see if i'm thinking straightforward here...
our team started to work with a few serial commands on MPLAB used to communicate with the camera. As an example, we wrote the following code for the SL (sleep) command:

void Sleep_Mode(unsigned char active)
{
Write_Camera_Serial_Port('S');
Write_Camera_Serial_Port('L');
Write_Camera_Serial_Port(1);
Write_Camera_Serial_Port(active);
Write_Camera_Serial_Port('\r');
}

First off, one point we were discussing was related as to whether the "Write_Camera_Serial_Port('\r');" was necessary or not. Secondly, should the function return any values whatsoever?...

Any help at all would be greatly appreciated, as we're still a bit unsure as to how these serial commands work properly...so here's just a callout to all of you programmers out there who are less "confused"...

Thanks ...

Alan Anderson
24-01-2006, 14:53
Kevin's code puts the camera in "raw" mode, which does not want the '\r' after the parameters. The first byte after the command (here it's a 1) says how many more bytes will follow. I'm pretty sure an extraneous return at that point will have a real chance of waking the camera up immediately after you tell it to sleep.

I don't have a camera handy to test whether or not an ACK comes back after a sleep command, but it's easy for you to connect the camera serial port directly to a terminal and try it for yourself.

tribotec_ca88
24-01-2006, 16:26
The first byte after the command (here it's a 1) says how many more bytes will follow.
OK... that was something that wasn't stated clearly in the code (or at least I don't recall it being so), but we had a pretty good idea it had something to do with the number of bytes after we noticed there was a "6" in the TC (Track Color) command :D ...

I don't have a camera handy to test whether or not an ACK comes back after a sleep command, but it's easy for you to connect the camera serial port directly to a terminal and try it for yourself.
I imagine an ACK string should be returned (as explained in the "Serial Commands" part of the manual) ... but does anyone know for sure?

Quick thought...on commands such as GS (Get servo) where you get a return value (in this case, the last position sent to a specific servo), where exactly should these values show up ? (on MPLAB, because on Hyperterminal i believe they show up after the ACK message, if i'm not mistaken...) Would they appear right on the Terminal window on IFI Loader??? Or would I have to set some sort of variable ready to receive the command's return value?