source: titan/titan/hwtest.h @ 24223

Last change on this file since 24223 was 22821, checked in by nit, 11 years ago

[titan] update hwtest

File size: 21.5 KB
Line 
1#ifndef HWTEST_H
2#define HWTEST_H
3
4#ifndef IOCTL_GET_IS_CARD_PRESENT
5#define IOCTL_GET_IS_CARD_PRESENT       _IOW('s', 8, uint32_t)
6#endif
7
8//DVB-S
9//#define TEST_S11_FREQ   10900000 // 4000, 22Khz off
10//#define TEST_S11_SYMBOL  28125000
11//#define TEST_S11_POL    _POLAR_HOR
12//#define TEST_S11_VIDEO_PID  380
13//#define TEST_S11_AUDIO_PID    381
14//#define TEST_S11_PCR_PID  380
15//test_channel.videoType = V_MP2;
16//test_channel.audioType = A_MP1;
17
18//ASIASAT-5, 4000H28125 - France 24 English (fec: 3/4)
19//testtransponder1s=0#4000000#0#192#28125000#?#3#?#?#?#0
20//testchannel1s=8#0#1#380#381
21
22//Sat 19.2 (ProSieben)
23//testtransponder1s=0#12544750#0#192#22000000#0#4#2#0#2#0
24//testchannel1s=17501#0#1#511#512
25
26//DVB-S2
27//#define TEST_S12_FREQ   10767000 // 4132, 22Khz off
28//#define TEST_S12_SYMBOL  10670000
29//#define TEST_S12_POL    _POLAR_HOR
30//#define TEST_S12_VIDEO_PID  711
31//#define TEST_S12_AUDIO_PID    731
32//#define TEST_S12_PCR_PID  711
33//test_channel.videoType = V_H264;
34//test_channel.audioType = A_MP1;
35
36//ASIASAT-5, 4132H10670 - Trace Urban English (modulation: 8PSK, fec: 3/5)
37//testtransponder2s=0#4132000#0#192#10670000#2#7#?#?#?#1
38//testchannel2s=15#1#1#711#731
39
40//Sat 19.2 (ZDF HD)
41//testtransponder2s=0#11361750#0#192#22000000#2#2#2#0#2#1
42//testchannel2s=11110#1#1#6110#6120
43
44//DVB-T
45//#define TEST_T1_FREQ   5060000
46//#define TEST_T1_BW    8
47//#define TEST_T1_VIDEO_PID  305
48//#define TEST_T1_AUDIO_PID  306
49//#define TEST_T1_PCR_PID  305
50//test_channel.videoType = V_MP2;
51//test_channel.audioType = A_MP1;
52
53//DVB-C
54//#define TEST_C1_FREQ   3540000
55//#define TEST_C1_SYMBOL   6900000
56//#define TEST_C1_VIDEO_PID  305
57//#define TEST_C1_AUDIO_PID  306
58//#define TEST_C1_PCR_PID  305
59//#define TEST_C1_CAB_QAM   _QAMMODE_64
60//test_channel.videoType = V_MP2;
61//test_channel.audioType = A_MP1;
62
63void testzap(char* testtransponder, char* testchannel)
64{
65        uint64_t tpid = 99;
66        uint8_t fetype = 0, polarization = 0, modulation = 0, fec = 0, pilot = 0, rolloff = 0, inversion = 0, system = 0;
67        int orbitalpos = 0;
68        unsigned int frequency = 0, symbolrate = 0;
69                               
70        int serviceid = 0;
71        int8_t videocodec = 0, audiocodec = 0;
72        int16_t videopid = 0, audiopid = 0;
73                               
74        char* tmpstr = NULL, *tmpstr1 = NULL;
75        struct transponder* tp = NULL;
76        struct channel* chnode = NULL;
77                               
78        tmpstr = ostrcat(testtransponder, NULL, 0, 0);
79        if(tmpstr == NULL)
80                textbox(_("Message"), _("testtransponder not found"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
81        else
82        {
83                int ret = sscanf(tmpstr, "%"SCNu8"#%d#%"SCNu8"#%d#%d#%"SCNu8"#%"SCNu8"#%"SCNu8"#%"SCNu8"#%"SCNu8"#%"SCNu8, &fetype, &frequency, &polarization, &orbitalpos, &symbolrate, &modulation, &fec, &pilot, &rolloff, &inversion, &system);
84                if(ret != 11)
85                        textbox(_("Message"), _("testtransponder entry not ok"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                   
86                else
87                {
88                        tp = createtransponder(tpid, fetype, orbitalpos, frequency, inversion, symbolrate, polarization, fec, modulation, rolloff, pilot, system);                     
89                        if(tp == NULL)
90                                textbox(_("Message"), _("can't create new transponer"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                   
91                        else
92                        {
93                                tmpstr1 = ostrcat(testchannel, NULL, 0, 0);
94                                if(tmpstr1 == NULL)
95                                        textbox(_("Message"), _("testchannel not found"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
96                                else
97                                {
98                                        int ret = sscanf(tmpstr1, "%d#%"SCNu8"#%"SCNu8"#%"SCNu16"#%"SCNu16, &serviceid, &videocodec, &audiocodec, &videopid, &audiopid);
99                                        if(ret != 5)
100                                                textbox(_("Message"), _("testchannel entry not ok"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                       
101                                        else
102                                        {
103                                                chnode = createchannel("testchannel", tpid, 0, serviceid, 99, 0, videocodec, audiocodec, videopid, audiopid, 0);
104                                                if(chnode == NULL)
105                                                        textbox(_("Message"), _("can't create new channel"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                       
106                                                else
107                                                        servicecheckret(servicestart(chnode, NULL, NULL, 5), 0);
108                                        }
109                                }
110                        }
111                }
112        }
113
114        //del channel from service, so we can delete it
115        m_lock(&status.servicemutex, 2);
116        struct service* snode = service;
117
118        while(snode != NULL)
119        {
120                if(snode->channel == chnode)
121                        snode->channel = NULL;
122                snode = snode->next;
123        }
124        m_unlock(&status.servicemutex, 2);
125
126        delchannel(serviceid, tpid, 1);
127        deltransponder(tp);
128        free(tmpstr); tmpstr = NULL;
129        free(tmpstr1); tmpstr1 = NULL;
130}
131
132void screenhwtest()
133{
134        struct menulist* mlist = NULL, *mbox = NULL;
135        struct skin* load = getscreen("loading");
136        struct dvbdev* dvbnode = dvbdev;
137        struct channel* lastchannel = status.aktservice->channel;
138       
139        while(dvbnode != NULL)
140        {
141                if(dvbnode->type == FRONTENDDEV && dvbnode->feinfo != NULL)
142                {
143                        if(dvbnode->feinfo->type == FE_QPSK)
144                        {
145                                char* tmpstr = ostrcat("[S]Lock & Search", " (", 0, 0);
146                                tmpstr = ostrcat(tmpstr, dvbnode->feinfo->name, 1, 0);
147                                tmpstr = ostrcat(tmpstr, ")", 1, 0);
148                                addmenulist(&mlist, tmpstr, NULL, NULL, 0, 0);
149                        }
150                        if(dvbnode->feinfo->type == FE_OFDM)
151                        {
152                                char* tmpstr = ostrcat("[T]Lock & Search", " (", 0, 0);
153                                tmpstr = ostrcat(tmpstr, dvbnode->feinfo->name, 1, 0);
154                                tmpstr = ostrcat(tmpstr, ")", 1, 0);
155                                addmenulist(&mlist, tmpstr, NULL, NULL, 0, 0);
156                        }
157                        if(dvbnode->feinfo->type == FE_QAM)
158                        {
159                                char* tmpstr = ostrcat("[C]Lock & Search", " (", 0, 0);
160                                tmpstr = ostrcat(tmpstr, dvbnode->feinfo->name, 1, 0);
161                                tmpstr = ostrcat(tmpstr, ")", 1, 0);
162                                addmenulist(&mlist, tmpstr, NULL, NULL, 0, 0);
163                        }
164                }
165               
166                dvbnode = dvbnode->next;
167        }
168        addmenulist(&mlist, "Front Display", NULL, NULL, 0, 0);
169        addmenulist(&mlist, "Front Key", NULL, NULL, 0, 0);
170        //addmenulist(&mlist, "Color Bar", NULL, NULL, 0, 0);
171        //addmenulist(&mlist, "SCART 4:3 / 16:9", NULL, NULL, 0, 0);
172        addmenulist(&mlist, "Smartcard", NULL, NULL, 0, 0);
173        addmenulist(&mlist, "Network", NULL, NULL, 0, 0);
174        addmenulist(&mlist, "USB Port", NULL, NULL, 0, 0);
175        addmenulist(&mlist, "CAM", NULL, NULL, 0, 0);
176        addmenulist(&mlist, "RS232", NULL, NULL, 0, 0);
177        addmenulist(&mlist, "LNB", NULL, NULL, 0, 0);
178        addmenulist(&mlist, "Flash/Nand Check", NULL, NULL, 0, 0);
179       
180        while(1)
181        {
182                mbox = menulistbox(mlist, NULL, "Hardware Test", NULL, NULL, 1, 0);
183               
184                if(mbox != NULL)
185                {
186                        setmenulistdefault(mlist, mbox->name);
187                        if(ostrstr(mbox->name, "[S]Lock & Search") != NULL)
188                        {
189                                clearscreen(load);
190                                drawscreen(load, 0, 0);
191                                resettvpic();                           
192//                              testzap(getconfig("testtransponder1s", NULL), getconfig("testchannel1s", NULL));
193//                              textbox(_("Message"), _("Press OK or EXIT"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 400, 0, 0);
194//                              testzap(getconfig("testtransponder2s", NULL), getconfig("testchannel2s", NULL));
195//                              textbox(_("Message"), _("Press OK or EXIT"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 400, 0, 0);
196                                testzap("0#10900000#0#192#28125000#1#3#2#3#2#0", "8#0#1#380#381");
197                                textbox(_("Message"), _("Press OK or EXIT"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 400, 0, 0);
198                                servicestart(lastchannel, NULL, NULL, 0);       
199                        }
200                       
201                        if(ostrstr(mbox->name, "[T]Lock & Search") != NULL)
202                        {
203                                //struct transponder* createtransponder(uint64_t id, FE_OFDM, int orbitalpos, TEST_S2_FREQ, int inversion, TEST_S2_SYMBOL, int polarization, int fec, int modulation, int rolloff, int pilot, int system);                     
204                        }
205                       
206                        if(ostrstr(mbox->name, "[C]Lock & Search") != NULL)
207                        {
208                                //struct transponder* createtransponder(uint64_t id, FE_QAM, int orbitalpos, TEST_S2_FREQ, int inversion, TEST_S2_SYMBOL, int polarization, int fec, int modulation, int rolloff, int pilot, int system);                       
209                        }
210                       
211                        if(ostrcmp(mbox->name, "Front Display") == 0)
212                        {
213                                int i = 0;
214                                char* tmpstr = NULL;
215
216                                status.updatevfd = PAUSE;
217                                for(i = 0; i < 10; i++)
218                                {
219                                        tmpstr = ostrcat(oitoa(i), oitoa(i), 1, 1);
220                                        tmpstr = ostrcat(tmpstr, oitoa(i), 1, 1);
221                                        tmpstr = ostrcat(tmpstr, oitoa(i), 1, 1);
222                                        writevfd(tmpstr);
223                                        free(tmpstr); tmpstr = NULL;
224                                        usleep(600000);
225                                }
226                                free(tmpstr); tmpstr = NULL;
227                                status.updatevfd = START;
228                        }
229                       
230                        if(ostrcmp(mbox->name, "Front Key") == 0)
231                        {
232                                char* tmpload = ostrcat(load->text, NULL, 0, 0);
233                                char* tmpstr = NULL;
234                                while(1)
235                                {
236                                        changetext(load, _("Press Front Key"));
237                                        clearscreen(load);
238                                        drawscreen(load, 0, 0);
239                                        int rcret = waitrc(NULL, 0, 0);
240                                       
241                                        if(rcret == getrcconfigint("rcexit", NULL) || rcret == getrcconfigint("rcok", NULL))
242                                                break;
243                                       
244                                        if(rcret == getrcconfigint("rcup", NULL)) tmpstr = ostrcat(tmpstr, "LEFT", 1, 0);
245                                        if(rcret == getrcconfigint("rcdown", NULL)) tmpstr = ostrcat(tmpstr, "RIGHT", 1, 0);
246                                        if(rcret == getrcconfigint("rcpower", NULL)) tmpstr = ostrcat(tmpstr, "POWER", 1, 0);
247                                        changetext(load, tmpstr);
248                                        clearscreen(load);
249                                        drawscreen(load, 0, 0);
250                                        free(tmpstr); tmpstr = NULL;
251                                               
252                                        sleep(1); 
253                                }
254                                changetext(load, tmpload);
255                                free(tmpload); tmpload = NULL;                 
256                        }
257                       
258                        if(ostrcmp(mbox->name, "Color Bar") == 0)
259                        {
260                                char* tmpstr = NULL;
261                                char* tmpload = ostrcat(load->text, NULL, 0, 0);
262                                long tmpbgcol = load->bgcol;
263                                int i = 0;
264                                long col = 0;
265                               
266                                for(i = 0; i < 3; i++)
267                                {
268                                        if(i == 0)
269                                        {
270                                                tmpstr = ostrcat(tmpstr, _("RED"), 1, 0);
271                                                col = 0x00FF0000;
272                                        }
273                                        if(i == 1)
274                                        {
275                                                tmpstr = ostrcat(tmpstr, _("GREEN"), 1, 0);
276                                                col = 0x0000FF00;
277                                        }
278                                        if(i == 2)
279                                        {
280                                                tmpstr = ostrcat(tmpstr, _("BLUE"), 1, 0);
281                                                col = 0x000000FF;
282                                        }
283                                        changetext(load, tmpstr);
284                                        load->bgcol = col;
285                                        clearscreen(load);
286                                        drawscreen(load, 0, 0);
287                                        free(tmpstr); tmpstr = NULL;
288                                        sleep(1);
289                                }
290                               
291                                free(tmpstr); tmpstr = NULL;
292                                changetext(load, tmpload);
293                                load->bgcol = tmpbgcol;                 
294                        }
295                       
296                        if(ostrcmp(mbox->name, "SCART 4:3 / 16:9") == 0)
297                        {
298                                char* tmpload = ostrcat(load->text, NULL, 0, 0);
299                                char* tmpstr = NULL;
300
301                                tmpstr = ostrcat(tmpstr, "4:3", 1, 0);
302                                changetext(load, tmpstr);
303                                clearscreen(load);
304                                drawscreen(load, 0, 0);
305                                setaspect(tmpstr);
306                                sleep(1);
307
308                                free(tmpstr); tmpstr = NULL;
309                                tmpstr = ostrcat(tmpstr, "16:9", 1, 0);
310                                changetext(load, tmpstr);
311                                clearscreen(load);
312                                drawscreen(load, 0, 0);
313                                setaspect(tmpstr);
314                                sleep(1);
315
316                                free(tmpstr); tmpstr = NULL;
317                                changetext(load, tmpload);
318                        }
319                       
320                        if(ostrcmp(mbox->name, "Smartcard") == 0)
321                        {
322                                uint32_t status = 0;
323                                int smartcardcount = 0;
324                                char* tmpstr = NULL, *tmpstr1 = NULL;
325                                unsigned char buf[1] = {0};
326                               
327                                drawscreen(load, 0, 0);
328                                dvbnode = dvbdev;
329                                while(dvbnode != NULL)
330                                {
331                                        if(dvbnode->type == SCDEV)
332                                        {
333                                                smartcardcount++;
334                                                status = 0;
335                                                dvbnode->fd = scopendirect(dvbnode->dev);
336                                                scgetiscardpresent(dvbnode, &status);
337                                                if(status == 1)
338                                                {
339                                                        status = 0;
340                                                        if(scsetreset(dvbnode) == 0)
341                                                        {
342                                                                sciparameters params;
343                                                                params.ETU = 372;
344                                                                params.EGT = 3;
345                                                                params.fs = 5;
346                                                                params.T = 0;
347                                                               
348                                                                if(scsetparameters(dvbnode, &params) == 0)
349                                                                {
350                                                                        if(dvbreadfd(dvbnode->fd, buf, 0, 1, -1, 1) == 1)
351                                                                                status = 1;
352                                                                }
353                                                        }                                               
354                                                }
355                                                scclose(dvbnode, -1);
356                                               
357                                                if(status == 1)
358                                                {
359                                                        tmpstr1 = ostrcat(tmpstr1, _("Smartcard "), 1, 0);
360                                                        tmpstr1 = ostrcat(tmpstr1, oitoa(smartcardcount), 1, 1);
361                                                        tmpstr1 = ostrcat(tmpstr1, _(": Present\n"), 1, 0);
362                                                }
363                                                else
364                                                {
365                                                        tmpstr1 = ostrcat(tmpstr1, _("Smartcard "), 1, 0);
366                                                        tmpstr1 = ostrcat(tmpstr1, oitoa(smartcardcount), 1, 1);
367                                                        tmpstr1 = ostrcat(tmpstr1, _(": Not Present\n"), 1, 0);
368                                                }
369                                        }
370                                       
371                                        dvbnode = dvbnode->next;
372                                }
373                                clearscreen(load);
374                               
375                                tmpstr = ostrcat(_("Smartcard Ports found: "), oitoa(smartcardcount), 0, 1);
376                                tmpstr = ostrcat(tmpstr, "\n\n", 1, 0);
377                                tmpstr = ostrcat(tmpstr, tmpstr1, 1, 0);
378                                                                       
379                                textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 400, 0, 0);                     
380                       
381                                free(tmpstr); tmpstr = NULL;
382                                free(tmpstr1); tmpstr1 = NULL;
383                        }
384                       
385                        if(ostrcmp(mbox->name, "Network") == 0)
386                        {
387                                struct inetwork* inode = inetwork;
388                               
389                                while(inode != NULL)
390                                {
391                                        if(ostrcmp(inode->device, "eth0") == 0)
392                                                break;
393                                        inode = inode->next;
394                                }
395                               
396                                if(inode != NULL)
397                                {
398                                        char* tmpstr = ostrcat(inode->device, ": ", 0, 0);
399                                        tmpstr = ostrcat(tmpstr, inode->ip, 0, 0);
400                                        textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                     
401                                        free(tmpstr); tmpstr = NULL;
402                                }
403                        }
404                       
405                        if(ostrcmp(mbox->name, "USB Port") == 0)
406                        {
407                                int usbcount = 0, found = 0, i = 0;
408                                struct hdd* hddnode = NULL;
409                                char* tmpstr = NULL;
410                               
411                                if(file_exist("/sys/bus/usb/devices/usb1") == 1) usbcount++;
412                                if(file_exist("/sys/bus/usb/devices/usb2") == 1) usbcount++;
413                                if(file_exist("/sys/bus/usb/devices/usb3") == 1) usbcount++;
414                                if(file_exist("/sys/bus/usb/devices/usb4") == 1) usbcount++;
415                               
416                                tmpstr = ostrcat(_("USB Ports found: "), oitoa(usbcount), 0, 1);
417                                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
418                                addhddall();
419                               
420                                hddnode = hdd;
421                                while(hddnode != NULL)
422                                {
423                                        if(hddnode->partition == 0)
424                                        {
425                                                found++;
426                                                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
427                                                tmpstr = ostrcat(tmpstr, _("USB "), 1, 0);
428                                                tmpstr = ostrcat(tmpstr, oitoa(found), 1, 1);
429                                                tmpstr = ostrcat(tmpstr, " : ", 1, 0);
430                                                tmpstr = ostrcat(tmpstr, hddnode->device, 1, 0);
431                                                tmpstr = ostrcat(tmpstr, _(" - OKAY!"), 1, 0);
432                                        }
433                                        hddnode = hddnode->next;
434                                }
435                               
436                                found++; usbcount++;
437                                for(i = found; i < usbcount; i++)
438                                {
439                                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
440                                        tmpstr = ostrcat(tmpstr, _("USB "), 1, 0);
441                                        tmpstr = ostrcat(tmpstr, oitoa(i), 1, 1);
442                                        tmpstr = ostrcat(tmpstr, _(" : NOT OKAY!"), 1, 0);
443                                }
444                               
445                                textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 400, 0, 0);                     
446                                free(tmpstr); tmpstr = NULL;
447                        }
448                       
449                        if(ostrcmp(mbox->name, "CAM") == 0)
450                        {
451                                int cicount = 0;
452                                char* tmpstr = NULL, *tmpstr1 = NULL;
453                                dvbnode = dvbdev;
454       
455                                while(dvbnode != NULL)
456                                {
457                                        if(dvbnode->type == CIDEV)
458                                        {
459                                                cicount++;
460                                               
461                                                tmpstr = ostrcat(tmpstr, _("Slot "), 1, 0);
462                                                tmpstr = ostrcat(tmpstr, oitoa(cicount), 1, 1);
463                                                tmpstr = ostrcat(tmpstr, ": ", 1, 0);
464                                                if(dvbnode->caslot != NULL)
465                                                {
466                                                        if(dvbnode->caslot->name == NULL || dvbnode->caslot->status == 0)
467                                                                tmpstr = ostrcat(tmpstr, _("unknown"), 1, 0);
468                                                        else
469                                                                tmpstr = ostrcat(tmpstr, dvbnode->caslot->name, 1, 0);
470                                                               
471                                                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
472                                                }
473                                        }
474                                               
475                                        dvbnode = dvbnode->next;
476                                }
477                               
478                                tmpstr1 = ostrcat(_("CAM Ports found: "), oitoa(cicount), 0, 1);
479                                tmpstr1 = ostrcat(tmpstr1, "\n\n", 1, 0);
480                                tmpstr = ostrcat(tmpstr1, tmpstr, 0, 1);
481                                textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 400, 0, 0);                     
482                                free(tmpstr); tmpstr = NULL;
483                                free(tmpstr1); tmpstr1 = NULL;                 
484                        }
485                       
486                        if(ostrcmp(mbox->name, "RS232") == 0)
487                        {
488                                int exist = 1, count = 0, okA = 0, okB = 0, okC = 0, okD = 0;
489                                unsigned char tmpwr[4] = {0};
490                                unsigned char tmprd[1] = {0};
491                               
492                                drawscreen(load, 0, 0);
493                               
494                                tmpwr[0] = 'A'; //65
495                                tmpwr[1] = 'B'; //66
496                                tmpwr[2] = 'C'; //67
497                                tmpwr[3] = 'D'; //68
498                               
499                                if(!file_exist(SERIALDEV) == 1)
500                                {
501                                        mknod(SERIALDEV, S_IFCHR | 0666, makedev(204, 40));
502                                        exist = 0;
503                                }
504                               
505                                int fd = open(SERIALDEV, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
506                                if(fd >= 0)
507                                {
508                                        //struct termios port_settings;      // structure to store the port settings in
509                                        int ret = 0;
510                                       
511                                        //tcgetattr(fd, &port_settings);
512
513                                        //cfsetispeed(&port_settings, B9600);    // set baud rates
514                                        //cfsetospeed(&port_settings, B9600);
515                       
516                                        //port_settings.c_cflag |= (CLOCAL | CREAD);
517                                        //port_settings.c_cflag &= ~PARENB;    // set no parity, stop bits, data bits
518                                        //port_settings.c_cflag &= ~CSTOPB;
519                                        //port_settings.c_cflag &= ~CSIZE;
520                                        //port_settings.c_cflag |= CS8;
521                                        //tcsetattr(fd, TCSANOW, &port_settings);
522
523                                        tcflush(fd, TCIOFLUSH);
524
525                                        ret = dvbwrite(fd, tmpwr, 4, -1);
526                                        if(ret != 4)
527                                        {
528                                                err("write %s (ret=%d)", SERIALDEV, ret);
529                                        }
530
531                                        while(dvbreadfd(fd, tmprd, 0, 1, -1, 0) == 1 && count < 200)
532                                        {
533                                                if(tmprd[0] == 'A') okA = 1;
534                                                if(tmprd[0] == 'B') okB = 1;
535                                                if(tmprd[0] == 'C') okC = 1;
536                                                if(tmprd[0] == 'D') okD = 1;
537                                               
538                                                count++;       
539                                        }
540                                       
541                                        close(fd);
542                                }
543                                else
544                                {
545                                        perr("open %s", SERIALDEV);
546                                }
547                               
548                                if(exist == 0) unlink(SERIALDEV);
549                               
550                                clearscreen(load);
551
552                                if(okA == 1 && okB == 1 && okC == 1 && okD == 1)
553                                        textbox(_("Message"), _("SUCESS Serial Port"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                     
554                                else
555                                        textbox(_("Message"), _("FAIL Serial Port"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                       
556                        }
557                       
558                        if(ostrcmp(mbox->name, "LNB") == 0)
559                        {
560                                char* tmpstr = NULL;
561                                int ret1 = 0, ret2 = 0;
562                       
563                                ret1 = fesetvoltage(status.aktservice->fedev, SEC_VOLTAGE_OFF, 15);
564                                ret2 = fesettone(status.aktservice->fedev, SEC_TONE_OFF, 15);
565                                if(ret1 == 0 && ret2 == 0)
566                                        tmpstr = ostrcat(tmpstr, _("LNB off / 22K off: OK\n"), 1, 0);
567                                else
568                                        tmpstr = ostrcat(tmpstr, _("LNB off / 22K off: NOT OK\n"), 1, 0);
569                                textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
570                                free(tmpstr); tmpstr = NULL;
571                               
572                                ret1 = fesetvoltage(status.aktservice->fedev, SEC_VOLTAGE_18, 15);
573                                ret2 = fesettone(status.aktservice->fedev, SEC_TONE_OFF, 15);
574                                if(ret1 == 0 && ret2 == 0)
575                                        tmpstr = ostrcat(tmpstr, _("LNB 18V / 22K off: OK\n"), 1, 0);
576                                else
577                                        tmpstr = ostrcat(tmpstr, _("LNB 18V / 22K off: NOT OK\n"), 1, 0);
578                                textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
579                                free(tmpstr); tmpstr = NULL;
580                               
581                                ret1 = fesetvoltage(status.aktservice->fedev, SEC_VOLTAGE_13, 15);
582                                ret2 = fesettone(status.aktservice->fedev, SEC_TONE_OFF, 15);
583                                if(ret1 == 0 && ret2 == 0)
584                                        tmpstr = ostrcat(tmpstr, _("LNB 13V / 22K off: OK\n"), 1, 0);
585                                else
586                                        tmpstr = ostrcat(tmpstr, _("LNB 13V / 22K off: NOT OK\n"), 1, 0);
587                                textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
588                                free(tmpstr); tmpstr = NULL;
589                               
590                                ret1 = fesetvoltage(status.aktservice->fedev, SEC_VOLTAGE_13, 15);
591                                ret2 = fesettone(status.aktservice->fedev, SEC_TONE_ON, 15);
592                                if(ret1 == 0 && ret2 == 0)
593                                        tmpstr = ostrcat(tmpstr, _("LNB 13V / 22K on: OK\n"), 1, 0);
594                                else
595                                        tmpstr = ostrcat(tmpstr, _("LNB 13V / 22K on: NOT OK\n"), 1, 0);
596                                textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0);
597                                free(tmpstr); tmpstr = NULL;
598                               
599                                drawscreen(load, 0, 0);
600                                servicestart(lastchannel, NULL, NULL, 5);
601                                clearscreen(load);     
602                        }
603                        if(ostrcmp(mbox->name, "Flash/Nand Check") == 0)
604                        {
605                                int ret1 = 0, ret2 = 0, i = 0;
606                                char* tmpstr = NULL, *tmpstr1 = NULL;
607                               
608                                for(i = 0; i < 20; i++)
609                                        tmpstr = ostrcat(tmpstr, "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 1, 0);
610                               
611                                //check /var
612                                ret1 = writesys("/var/hwtest.txt", tmpstr, 0);
613                                if(ret1 == 0)
614                                {
615                                        tmpstr1 = readsys("/var/hwtest.txt", 1);
616                                        if(ostrcmp(tmpstr, tmpstr1) != 0) ret1 = 1;
617                                }
618                               
619                                if(ret1 == 0)
620                                        ret1 = unlink("/var/hwtest.txt");
621                                else
622                                        unlink("/var/hwtest.txt");
623                               
624                                free(tmpstr1); tmpstr1 = NULL;
625                               
626                                //check /mnt
627                                ret2 = writesys("/mnt/hwtest.txt", tmpstr, 0);
628                                if(ret2 == 0)
629                                {
630                                        tmpstr1 = readsys("/mnt/hwtest.txt", 1);
631                                        if(ostrcmp(tmpstr, tmpstr1) != 0) ret2 = 1;
632                                }
633                               
634                                if(ret2 == 0)
635                                        ret2 = unlink("/mnt/hwtest.txt");
636                                else
637                                        unlink("/mnt/hwtest.txt");
638                               
639                                free(tmpstr); tmpstr = NULL;
640                                free(tmpstr1); tmpstr1 = NULL;
641
642                                if(ret1 == 0 && ret2 == 0)
643                                        textbox(_("Message"), _("SUCESS Flash/Nand"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                     
644                                else if(ret1 != 0 && ret2 != 0)
645                                        textbox(_("Message"), _("FAIL Flash/Nand (/var and /mnt)"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
646                                else if(ret1 != 0)
647                                        textbox(_("Message"), _("FAIL Flash/Nand (/var)"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
648                                else if(ret2 != 0)
649                                        textbox(_("Message"), _("FAIL Flash/Nand (/mnt)"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);                 
650                        }
651                }
652                else
653                        break;
654        }
655
656        resettvpic();   
657        freemenulist(mlist, 1); mlist = NULL;
658}
659
660#endif
Note: See TracBrowser for help on using the repository browser.