2 Replies Latest reply on Aug 14, 2014 2:02 PM by pcribbin

    Galileo help needed

    pcribbin

      I'm trying to hook up a TTL camera to the Galileo board but I'm no joy....can someone help me?

      I am going by Use LinkSprite JPEG Camera to Take Picture and Store to a SD card | LinkSprite Learning Center without the SD breakout board and I'm getting the error

       

      C:\Users\pcribbin\Documents\arduino-1.5.3\libraries\SoftwareSerial\arch\x86\SoftwareSerial.cpp: In constructor 'SoftwareSerial::SoftwareSerial(uint8_t, uint8_t, bool)':

      C:\Users\pcribbin\Documents\arduino-1.5.3\libraries\SoftwareSerial\arch\x86\SoftwareSerial.cpp:18:7: error: 'LINUX_SOFTSERIAL_TTY_OBJ' was not declared in this scope


        • 1. Re: Galileo help needed
          flummer

          Hi pcribbin,

           

          There is no SoftwareSerial on the Galileo, but contrary to the Arduino Uno, you can use the hardware serial port on pin 0 and 1 (called Serial1 in Arduino IDE) and still have debug informations to the computer via Serial as on the Arduino Uno.

           

          All you need to do is remove the software serial code on line 13 and  line 19 and change mySerial to Serial1 and of course move the connections to pin 0 and 1. I can't remember which is RX and which is TX, but you can look that up.

           

          That should make it work!

           

          /Thomas

          1 of 1 people found this helpful
          • 2. Re: Galileo help needed
            pcribbin

            Thank you flummer, that worked a treat.

            Now I'stuck and wondering would you or anyone else have any more sugeestions.

            I did get the code working and it saves a file pic.jpg to the memory card but while it's running in the Serial window it seems to keep on scrolling and it's blank. Also the file itself is 0KB. Reading through the code I'm not sure if it tells it to stop taking pics and write. There is a function there but does it call it?

             

            Can you help?

             

            // LinkSprite.com
            // Note:
            // 1. SD must be formated to FAT16
            // 2. As the buffer of softserial has 64 bytes, so the code read 32 bytes each time
            // 3. Please add the libaray to the lib path

            //  * SD card attached to SPI bus as follows:
            //** MOSI - pin 11
            // ** MISO - pin 12
            // ** CLK - pin 13
            // ** CS - pin 4

            //#include <SoftwareSerial.h>
            #include <SD.h>

            byte ZERO = 0x00;

            byte incomingbyte;
            //SoftwareSerial mySerial(2,3);          // Set Arduino pin 4 and 5 as softserial

            long int a=0x0000,j=0,k=0,count=0,i=0;
            uint8_t MH,ML;
            boolean EndFlag=0;

            File  myFile;

            void SendResetCmd();
            void SetBaudRateCmd();
            void SetImageSizeCmd();
            void SendTakePhotoCmd();
            void SendReadDataCmd();
            void StopTakePhotoCmd();

            void setup()
            {

            Serial.begin(38400);
            while (!Serial) {
            ; // wait for serial port to connect. Needed for Leonardo only
            }

            Serial1.begin(38400);

            Serial.print("Initializing SD card...");
            // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
            // Note that even if it's not used as the CS pin, the hardware SS pin
            // (10 on most Arduino boards, 53 on the Mega) must be left as an output
            // or the SD library functions will not work.
            pinMode(10, OUTPUT);

            if (!SD.begin(4)) {
            Serial.println("initialization failed!");
            return;
            }
            Serial.println("initialization done.");

            }

            void loop()
            {

            byte a[32];
            int ii;

            SendResetCmd();
            delay(4000);                            //Wait 2-3 second to send take picture command

            SendTakePhotoCmd();

            while(Serial1.available()>0)
            {
            incomingbyte=Serial1.read();
            }

            myFile = SD.open("pic.jpg", FILE_WRITE); //<strong><span style="color: #ff0000;">The file name should not be too long</span></strong>

            while(!EndFlag)
            {
            j=0;
            k=0;
            count=0;
            SendReadDataCmd();

            delay(20); //250 for regular

            while(Serial1.available()>0)
            {
            incomingbyte=Serial1.read();
            k++;
            if((k>5)&&(j<32)&&(!EndFlag))
            {
            a[j]=incomingbyte;
            if((a[j-1]==0xFF)&&(a[j]==0xD9))     //tell if the picture is finished
            EndFlag=1;
            j++;
            count++;
            }
            }

            for(j=0;j<count;j++)
            {
            if(a[j]<0x10)
            Serial.print("0");
            Serial.print(a[j],HEX);           // observe the image through serial port
            Serial.print(" ");
            }

            for(ii=0; ii<count; ii++)
            myFile.write(a[ii]);

            Serial.println();

             

            i++;
            }

            myFile.close();

            Serial.print("Finished writing data to file");

            while(1);

            }

            void SendResetCmd()
            {
            Serial1.write(0x56);
            Serial1.write(ZERO);
            Serial1.write(0x26);
            Serial1.write(ZERO);
            }

            void SetImageSizeCmd()
            {
            Serial1.write(0x56);
            Serial1.write(ZERO);
            Serial1.write(0x31);
            Serial1.write(0x05);
            Serial1.write(0x04);
            Serial1.write(0x01);
            Serial1.write(ZERO);
            Serial1.write(0x19);
            Serial1.write(0x11);
            }

            void SetBaudRateCmd()
            {
            Serial1.write(0x56);
            Serial1.write(ZERO);
            Serial1.write(0x24);
            Serial1.write(0x03);
            Serial1.write(0x01);
            Serial1.write(0x2A);
            Serial1.write(0xC8);

            }

            void SendTakePhotoCmd()
            {
            Serial1.write(0x56);
            Serial1.write(ZERO);
            Serial1.write(0x36);
            Serial1.write(0x01);
            Serial1.write(ZERO);
            }

            void SendReadDataCmd()
            {
            MH=a/0x100;
            ML=a%0x100;
            Serial1.write(0x56);
            Serial1.write(ZERO);
            Serial1.write(0x32);
            Serial1.write(0x0c);
            Serial1.write(ZERO);
            Serial1.write(0x0a);
            Serial1.write(ZERO);
            Serial1.write(ZERO);
            Serial1.write(MH);
            Serial1.write(ML);
            Serial1.write(ZERO);
            Serial1.write(ZERO);
            Serial1.write(ZERO);
            Serial1.write(0x20);
            Serial1.write(ZERO);
            Serial1.write(0x0a);
            a+=0x20;
            }

            void StopTakePhotoCmd()
            {
            Serial1.write(0x56);
            Serial1.write(ZERO);
            Serial1.write(0x36);
            Serial1.write(0x01);
            Serial1.write(0x03);
            }