Application - 3-axis accelerometer, GID-SSS/U10

出自 flip the world
前往: 導覽搜尋

GID-SSS/U10

Hardware

  • PRi
  • GID-SSS/U10 (USB2UART inside metal, output is USB signal)

Command Generator

//---------------------------------------------------------------------------
void  GIDSSS::ReadStop(void)
{
        CommandSend("100000000");
}
//---------------------------------------------------------------------------
bool  GIDSSS::ReadStart(void)
{
        CommandSend("000000000");
}
//---------------------------------------------------------------------------
void    GIDSSS::CommandSend(unsigned char *SendData)
{
        char data[16];
        unsigned char add,xor;

        add = '<';
        for(int i = 0;i< 9;i++)
                add += SendData[i];
        add = add & 0xFF;

        xor = '<';
        for(int i = 0;i< 9;i++)  xor = xor ^ SendData[i];
        xor = xor ^ add;

        data[0] = '<';
        for(int i = 0;i<9;i++)
                data[i+1] = SendData[i];
        data[10] = add;
        data[11] = xor;
        data[12] = '>';
        RS->Send(data,13);
}
//---------------------------------------------------------------------------

UART Commands

# start command <000000000ae>
echo -en '\x3C\x30\x30\x30\x30\x30\x30\x30\x30\x30\xEC\xE0\x3E' > /dev/ttyUSB0

# stop command <100000000ae>
echo -en '\x3C\x31\x30\x30\x30\x30\x30\x30\x30\x30\xED\xE0\x3E' > /dev/ttyUSB0

# live test <700000000ae>
echo -en '\x3C\x37\x30\x30\x30\x30\x30\x30\x30\x30\xF3\xF8\x3E' > /dev/ttyUSB0

Reference