Matteo,
I had the same problem.
I solved it by reducing the baud rate to 19200.
You'll have to change the code in 2 places:
1)
#define BAUDRATE B19200
2)
#ifdef DBG_STRING
printf("Set the baudrate to %d\n", BAUDRATE);
#endif
TXBuf[0] = 0xAA;
TXBuf[1] = 0x07;
TXBuf[2] = 0x5F; // 19200
TXBuf[3] = 0x01;
// TXBuf[2] = 0x1F; // 57600
// TXBuf[3] = 0x01;
// TXBuf[2] = 0x0F; // 115200
// TXBuf[3] = 0x01;
TXBuf[4] = 0x00;
TXBuf[5] = 0x00;
res=Send_Packet(fd, 200, TXBuf, 1, RXBuf, 6);
Now the communication works, but I still have another problem.
The file foto.jpg is corrupt, it is not recognized as a JPEG image.
Who knows what causes this?
- Harm
--- In [email protected], vitamona <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> some weeks ago i have bought an a very small camera (
> http://www.roundsolutions.com/cmos-camera/camera-module.htm) called
> Cam-vga 100.
> This camera have TTL logic level and a serial comunications, so it's
> perfect for Fox Board.
>
> My circuit is explained in this
> image:http://img245.imageshack.us/img245/6254/circuitdi8.jpg
> For acquire image from vga100 i used a example program written by
> Daniele De Santis, the source is here
> http://www.desantix.it/upload_file_articoli/FOX_CAMVGA100.zip.
>
> My problem is when i use tre program all work fine untill the vga100
> sent first packet image: the sync and setting was send and received
> correctly.
> This is the output:
>
> <start>
> [...]
> SYNC...23
> Ricevuto ACK e SYN
> ACK aa e d 0 0 0
> SYN aa d 0 0 0 0
> ACK e SYNC corretti
> Invio l'ok di sync
> INIZIALIZZAZONE DELLA CAM
>
> Setto il Baudrate
> Ricevuto 6
> ACK aa e 7 1 0 0
> Setto le impostazioni dell'immagine
> Ricevuto 6
> ACK aa e 1 2 0 0
> Setto le dimensioni dei pacchetti
> Ricevuto 6
> ACK aa e 6 3 0 0
> Get Picture
> ACK aa e 4 4 0 0
> SIZE aa a 5 d4 19 0
> Dimensioni dell'immagine 6612
> Download....
> Ancora : 6612 byte
> res:256 picturesize:6612 RetarnChr:512
> ATTENZIONE - RITRASMISSIONE!!!
> Ancora : 6612 byte
> res:512 picturesize:6612 RetarnChr:512
> DataSize:64244
> Segmentation fault
> <end>
>
> In the program is used the algorithm explained in the datasheet:
>
http://www.roundsolutions.com/cmos-camera/CAM-VGA100-User-Manual%20V2-0.pdf
>
> With a C program i was debugged the comunicatio from host to camera
> and viceversa this is the result:
>
> direction: host / cam
> syn client --> 0xAA 0x0D 0x00 0x00 0x00 0x00
> ACK vga <-- aa e d f 0 0
> SYN vga <-- aa d 0 0 0 0
> ok syn --> 0xAA 0x0E 0x0D 0x01 0x00 0x00
> set baudrate --> 0xAA 0x07 0x1F 0x01 0x00 0x00
> ACK baudrate <-- aa e 7 10 0 0
> image setting --> 0xAA 0x01 0x00 0x07 0x03 0x07
> ACK image sett <-- aa e 1 11 0 0
> setting pacchetto --> aa 6 8 0 2 0
> ACK pacchetto <-- aa e 6 17 0 0
> get picture --> 0xAA 0x04 0x05 0x00 0x00 0x00
> ACK picture <-- aa e 4 18 0 0
> SIZE picture <-- aa a 5 6c 53 0
> ACK image ID=0 --> aa e 0 0 0 0
> image data ID=1 <-- 0 0 fa 1 ff d8
> -----seems that the packet is too small of 512 bytes
> ACK image ID=0 --> aa e 0 0 0 0..................
> image data ID=? <-- 16 17 18 19 1a 25............
> ---segmentation fault
>
> The image packet is always equal.
>
> The segmentation fault is caused because the C program wait a value in
> an array but this value is oversize than array.
> I think this error happens for a problem in fox board serial pin or
> for a change add in teh firmware of the CAM-VGA100.
>
> Can anyone help me?
>
> I've tried with kernel 2.4 (glibc) and 2.6 (glibc) but the error still
> happening.
>
> Matteo
>