Commit 2395af70 authored by Your Name's avatar Your Name

new release

parent 1a9771f2
......@@ -90,10 +90,10 @@ void protocalAck(int fileusb)
}
// get angle and change into 16bits, return;
short getAngle(char *rece)
int getAngle(char *rece)
{
short angle;
short result = 0;
int angle;
int result = 0;
int i = 0;
char *p = rece;
while (*(p + i) != 'a' || *(p + i + 1) != 'n')
......@@ -108,7 +108,7 @@ short getAngle(char *rece)
i++;
continue;
}
short num = *(p + i) - '0';
int num = *(p + i) - '0';
result = result * 10 + num;
i++;
}
......@@ -274,6 +274,102 @@ void waitforReady_test(int fileuart) //test_version
}
int last = 0;
int reality = 0;
int dealAngle(int angle)
{
int result = 0;
int ret = 0;
if (last <= 1800){
int max = last + 1800;
if (angle >= last && angle <= max){
//turn leftji
result = angle - last;
//prshortf("sent message = %d\n", reality + result);
}
else {
//turn right
if (last > angle){
result = angle - last;
//prshortf("sent message = %d\n", reality + result);
}
else{
result = last + (3600 - angle);
result = -result;
//prshortf("sent message = %d\n", reality + result);
}
}
}
else{
int over = last - 1800;
if (angle >= over && angle <= last){
//turn right
result = angle - last;
//prshortf("sent message = %d\n", reality + result);
}
else {
//turn left
if ( angle < over){
result = angle + 3600 - last;
//prshortf("sent message = %d\n", reality + result);
}
else{
result = angle - last;
//prshortf("sent message = %d\n", reality + result);
}
}
}
ret = reality + result;
return ret;
}
void sentUart(char *buf, int fileuart, int fileusb)
{
if (count == 9) //9
{
strcat(totalbuf, buf);
int angle;
angle = getAngle(totalbuf);
printf("usb realize angle is = %d\n", angle);
int sentangle = dealAngle(3600 - angle);
last = angle;
//40 38 0B 06 00 0A 01 XX XX XX XX  CRCL CRCH
char message[13] = {0x40, 0x38, 0x0B, 0x06, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
sendMessageHead(1, message);
message[7] = (sentangle >> 24) & 0xff;
message[8] = (sentangle >> 16) & 0xff;
message[9] = (sentangle >> 8) & 0xff;
message[10] = sentangle & 0xff;
uint16_t crc = CrcValueCalc(message, 11);
message[11] = crc & 0xff;
message[12] = (crc >> 8) & 0xff;
if (g_callback != NULL)
{
char buf[256] = {0};
snprintf(buf, 256, "cvlc --play-and-exit --aout alsa --alsa-audio-device hw:%d,0 /usr/local/bin/Videos/aaaa.mp3 &", get_audio_device_id());
//system("mpg321 /usr/local/bin/Videos/aaaa.mp3 &");
//system("cvlc --play-and-exit --aout alsa --alsa-audio-device hw:2,0 /usr/local/bin/Videos/aaaa.mp3 &");
system(buf);
g_callback(g_callback_ctx, 2);
}
usleep(100);
write(fileuart, message, 13); printf(" %d\n", __LINE__);
count = 1;
memset(totalbuf, 0, 1024);
serialFlush(fileusb);
}
else
{
count++;
strcat(totalbuf, buf);
}
}
/*
void sentUart(char *buf, int fileuart, int fileusb) //changed
{
if (count == 9)
......@@ -301,14 +397,15 @@ void sentUart(char *buf, int fileuart, int fileusb) //changed
memset(totalbuf, 0, 1024);
protocalAck(fileusb);
if (g_callback != NULL){
char buf[256] = {0};
snprintf(buf, 256, "cvlc --play-and-exit --aout alsa --alsa-audio-device hw:%d,0 /usr/local/bin/Videos/aaaa.mp3 &", get_audio_device_id());
//system("mpg321 /usr/local/bin/Videos/aaaa.mp3 &");
//system("cvlc --play-and-exit --aout alsa --alsa-audio-device hw:2,0 /usr/local/bin/Videos/aaaa.mp3 &");
system(buf);
g_callback(g_callback_ctx, 2);
}
if (g_callback != NULL)
{
char buf[256] = {0};
snprintf(buf, 256, "cvlc --play-and-exit --aout alsa --alsa-audio-device hw:%d,0 /usr/local/bin/Videos/aaaa.mp3 &", get_audio_device_id());
//system("mpg321 /usr/local/bin/Videos/aaaa.mp3 &");
//system("cvlc --play-and-exit --aout alsa --alsa-audio-device hw:2,0 /usr/local/bin/Videos/aaaa.mp3 &");
system(buf);
g_callback(g_callback_ctx, 2);
}
//waitforReady_test(fileuart);
......@@ -320,6 +417,7 @@ void sentUart(char *buf, int fileuart, int fileusb) //changed
}
}
*/
void circleReading() //changed
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment