Esempio n. 1
0
        public SDStore()
        {
            sdResultCallBack = mySdCallback;

            Samraksh.SPOT.Hardware.EmoteDotNow.SD mysdCard = new Samraksh.SPOT.Hardware.EmoteDotNow.SD(sdResultCallBack);

            if (!Samraksh.SPOT.Hardware.EmoteDotNow.SD.Initialize())
            {
                Debug.Print("SD Card Initialization failed \n");
                //ADCTest.lcd.Write(Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_E, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_R, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_0, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_R);

                //cardAvailable = false;
                sdFail.Write(true);

                throw new InvalidOperationException("SD Card Initialization failed !!!");
            }
        }
Esempio n. 2
0
        public static void Main()
        {
            UInt16[] m_sendBuffer   = new UInt16[256];
            byte[]   m_serialBuffer = new byte[512];

            Samraksh.SPOT.Hardware.EmoteDotNow.SD.SDCallBackType sdResultCallBack = mySdCallback;

            //OutputPort error = new OutputPort(Samraksh.SPOT.Hardware.EmoteDotNow.Pins.GPIO_J12_PIN3, false);

            Samraksh.SPOT.Hardware.EmoteDotNow.SD mysd = new Samraksh.SPOT.Hardware.EmoteDotNow.SD(sdResultCallBack);

            if (!Samraksh.SPOT.Hardware.EmoteDotNow.SD.Initialize())
            {
                Debug.Print("SD Card Initialization failed \n");
                throw new Exception();
            }

            Debug.EnableGCMessages(false);

            Thread.Sleep(1000); //5000

            Samraksh.SPOT.Hardware.EmoteDotNow.EmoteLCD lcd;

            lcd = new Samraksh.SPOT.Hardware.EmoteDotNow.EmoteLCD();

            lcd.Initialize();

            lcd.Clear();

            lcd.Write(Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_E, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_X, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_F, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_L);

            UInt16 counter = 0;

            UInt32 readBytes = 0;

            bool readDone = false;

            serialPort           = new SerialPort("COM1");
            serialPort.BaudRate  = 115200;
            serialPort.Parity    = System.IO.Ports.Parity.None;
            serialPort.StopBits  = StopBits.One;
            serialPort.DataBits  = 8;
            serialPort.Handshake = Handshake.None;

            // serialPort.DataReceived += new SerialDataReceivedEventHandler(SerialPortHandler);

            //serialPort.Open();

            //Samraksh.SPOT.Hardware.EmoteDotNow.NOR.Initialize();

            lcd.Write(Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_E, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_X, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_F, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_L);

            Thread.Sleep(3000); //15000

            string output = "";

            while (true)
            {
                //Debug.Print("Read : " + readBytes.ToString() + "\n");

                output = "Data";

                lcd.Clear();

                lcd.Write(Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_E, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_X, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_F, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_L);

                //Thread.Sleep(15000);


                if (!Samraksh.SPOT.Hardware.EmoteDotNow.SD.Read(m_serialBuffer, 0, 512))
                {
                    //Debug.Print("SD Read failed\n");
                    //return false;
                    sdRead.Write(true);
                    sdRead.Write(false);
                }


                for (int i = 0; i < 64; i = i + 4)
                {
                    if ((m_serialBuffer[i] == 0x0c) && (m_serialBuffer[i + 1] == 0x0c) && (m_serialBuffer[i + 2] == 0x0c) && (m_serialBuffer[i + 3] == 0x0c))
                    {
                        readDone = true;
                    }
                }

                if (readDone == true)
                {
                    break;
                }

                /*
                 * conversion.Write(true);
                 * for (UInt16 i = 0; i < m_serialBuffer.Length; i++)
                 * {
                 *  output += m_serialBuffer[i].ToString() + ",";
                 * }
                 * conversion.Write(false);
                 */

                usartSend.Write(true);
                //Debug.Print(output.ToString());
                serialPort.Write(m_serialBuffer, 0, 512);
                usartSend.Write(false);

                //Debug.Print("\n");

                output = "";


                readBytes += 512;

                Thread.Sleep(25);
            }

            lcd.Clear();

            lcd.Write(Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_D, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_D, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_D, Samraksh.SPOT.Hardware.EmoteDotNow.LCD.CHAR_D);
            //Debug.Print("Read is complete \n");
        }