[T8TSK-227]Optimize sink code of factory test
Change-Id: Ieecbc1d3c93bc86b7002f23fc02b00ec53b53cc9
diff --git a/src/lynq/framework/lynq-ril-service/src/factory/lynq_factory.cpp b/src/lynq/framework/lynq-ril-service/src/factory/lynq_factory.cpp
index 561656e..113714d 100755
--- a/src/lynq/framework/lynq-ril-service/src/factory/lynq_factory.cpp
+++ b/src/lynq/framework/lynq-ril-service/src/factory/lynq_factory.cpp
@@ -874,38 +874,111 @@
}
}
-int lynq_test_sink(){
+int set_campare(char dev_buf[][40],char *buf_str[3])
+{
FILE *fp;
- char lynq_usb_dev[512] = {0};
- char lynq_usb_buf[512] = {0};
- char buf[512] = {0};
+ int k = 15;
+ int j;
+ char lynq_usb_buf[256] = {0};
+ char buf[256] = {0};
+ for(j=0;j++;j<3)
+ {
+ sprintf(lynq_usb_buf,"cat /sys/class/leds/led95%d:%s",k++, dev_buf[j]);
+ fp=popen(lynq_usb_buf, "r");
+ fgets(buf, sizeof(buf), fp);
+ if(strcmp(buf,buf_str[j]))
+ {
+ pclose(fp);
+ return -1;
+ }
+ pclose(fp);
+ }
+ return 0;
+}
+
+void lynq_test_sink(){
+ FILE *fp;
+ time_t start,end;
+ char lynq_usb_dev[256] = {0};
+ char lynq[256] = {0 };
+ char char_buf[16]={0};
+ char flag_buf[64] = {0};
+ char sink_state[16]={0};
int sink[3][3] = {{255,0,0},{0,255,0},{0,0,255}};
char dev_buf[][40]={{"green:cellular-radio/brightness"},{"green:cellular-quality/brightness"},{"red:system/brightness"}};
- int i;
- int j;
+ char *str_buf[3]={"0","0","0"};
+ int i,j,ret;
+ int state = 0;
int k = 15;
- char flag_buf[64] = {0};
- for(i = 0;i < 3;i++){
- bzero(flag_buf, 64);
- bzero(lynq_usb_buf, 512);
- bzero(buf, 512);
- k = 15;
- for(j = 0;j < 3;j++){
- bzero(lynq_usb_dev, 512);
- sprintf(lynq_usb_dev,"echo %d > /sys/class/leds/led95%d:%s 2>&1", sink[i][j], k++, dev_buf[j]);
- fp=popen(lynq_usb_dev, "r");
- }
- usleep(10000);
- sprintf(lynq_usb_buf,"cat /sys/bus/iio/devices/iio:device1/in_voltage4_input 2>&1");
- fp=popen(lynq_usb_buf, "r");
- fgets(buf, sizeof(buf), fp);
- sprintf(flag_buf, "%s%d%s%s%s", "SINK[", i+1, "]: ", buf, "\n");
- lynq_factory_response_ttyGS3(flag_buf);
+ for(i = 0;i < 3;i++)
+ {
+ bzero(flag_buf, 64);
+ k = 15;
+
+ switch(i)
+ {
+ case 0:
+ {
+ str_buf[0]="255";
+ str_buf[1]="0";
+ str_buf[2]="0";
+ break;
+ }
+
+ case 1:
+ {
+ str_buf[0]="0";
+ str_buf[1]="255";
+ str_buf[2]="0";
+ break;
+ }
+
+ case 2:
+ {
+ str_buf[0]="0";
+ str_buf[1]="0";
+ str_buf[2]="255";
+ break;
+ }
+ }
+ for(int h=0;h<20;h++)
+ {
+ for(j = 0;j < 3;j++)
+ {
+ bzero(lynq_usb_dev, 256);
+ sprintf(lynq_usb_dev,"echo %d > /sys/class/leds/led95%d:%s 2>&1", sink[i][j], k++, dev_buf[j]);
+ fp=popen(lynq_usb_dev, "r");
+ pclose(fp);
+ }
+ bzero(char_buf,16);
+ if(set_campare(dev_buf,str_buf))
+ {
+ continue;
+ }
+ sprintf(lynq,"cat /sys/bus/iio/devices/iio:device1/in_voltage4_input 2>&1");
+ fp=popen(lynq, "r");
+ fgets(char_buf, sizeof(char_buf), fp);
+
+ if(set_campare(dev_buf,str_buf))
+ {
+ continue;
+ }
+ sprintf(flag_buf, "%s%d%s%s%s", "SINK[", i+1, "]: ", char_buf, "\n");
+ lynq_factory_response_ttyGS3(flag_buf);
+ state =1;
+ break;
+ }
+ if(state == 0)
+ {
+ sprintf(flag_buf, "%s%d%s%s%s", "SINK[", i+1, "]: ", char_buf, "\n");
+ lynq_factory_response_ttyGS3(flag_buf);
+ }
}
- lynq_factory_response_ttyGS3("OK\r\n");
pclose(fp);
- return 1;
+ sprintf(sink_state,"OK\n");
+ lynq_factory_response_ttyGS3(sink_state);
+ return;
}
int lynq_check_pcie(void){