Subversion Repositories Projects

Rev

Rev 70 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70 Rev 81
Line 23... Line 23...
23
    public String mk_url=""; // buffer the url which is given in the constuctor for reconnectin purposes
23
    public String mk_url=""; // buffer the url which is given in the constuctor for reconnectin purposes
Line 24... Line 24...
24
   
24
   
25
    public MKLCD LCD;
25
    public MKLCD LCD;
26
    public MKVersion version;
26
    public MKVersion version;
-
 
27
    public MKDebugData debug_data;
27
    public MKDebugData debug_data;
28
    public MKStickData stick_data;
28
    public MKParamsParser params;
29
    public MKParamsParser params;
29
    public MKWatchDog watchdog;
30
    public MKWatchDog watchdog;
Line 30... Line 31...
30
    public MKProxy proxy=null;
31
    public MKProxy proxy=null;
Line 50... Line 51...
50
 
51
 
51
 
52
 
-
 
53
 
Line 52... Line 54...
52
 
54
    String name;
53
    String name;
55
    DUBwise root;
54
    DUBwise root;
56
    DUBwiseDebug debug;
-
 
57
 
55
   
58
    /******************  Section: public Methods ************************************************/
56
    /******************  Section: public Methods ************************************************/
59
    public MKCommunicator(DUBwise root_,DUBwiseDebug debug_)  
57
    public MKCommunicator(DUBwise root_)  
60
    {
-
 
61
        debug=debug_;
58
    {
62
        root=root_;
59
        root=root_;
63
        version=new MKVersion();
60
        version=new MKVersion();
64
        debug_data=new MKDebugData();
61
        debug_data=new MKDebugData();
65
        stick_data=new MKStickData();
62
        params=new MKParamsParser();
66
        params=new MKParamsParser();
Line 89... Line 93...
89
                // old call
93
            // old call
90
                // connection = (StreamConnection) Connector.open(mk_url, Connector.READ_WRITE);
94
            // connection = (StreamConnection) Connector.open(mk_url, Connector.READ_WRITE);
91
                reader=connection.openInputStream();
95
            reader=connection.openInputStream();
92
                writer=connection.openOutputStream();
96
            writer=connection.openOutputStream();
Line -... Line 97...
-
 
97
 
-
 
98
 
-
 
99
            //
-
 
100
            String magic="\rmk-mode\r";
-
 
101
            writer.write(magic.getBytes());
-
 
102
            writer.flush();
-
 
103
            //
-
 
104
 
93
               
105
 
94
                connection_start_time=System.currentTimeMillis();
106
            connection_start_time=System.currentTimeMillis();
95
                connected=true; // if we get here everything seems to be OK
107
            connected=true; // if we get here everything seems to be OK
96
                get_version();
108
            get_version();
97
                lcd_data_count=0;
109
            lcd_data_count=0;
Line 273... Line 285...
273
    }
285
    }
Line 274... Line 286...
274
 
286
 
275
 
287
 
276
    public void process_data(int[] data,int len)
-
 
277
    {
-
 
Line 278... Line 288...
278
        int[] decoded_data;
288
    public void process_data(int[] data,int len)
279
 
289
    {
Line 280... Line 290...
280
       
290
 
Line 298... Line 308...
298
               
308
               
299
            case '0':
309
            case '0':
300
            case '1':
310
            case '1':
301
            case '2':
311
            case '2':
302
            case '3':
-
 
303
                LCD.handle_lcd_data(Decode64(data,3,20),data[2]-(int)'0');
312
            case '3':
-
 
313
                lcd_data_count++;
-
 
314
                LCD.handle_lcd_data(Decode64(data,3,20),data[2]-(int)'0');
-
 
315
 
-
 
316
                break;
-
 
317
            case '4':
-
 
318
                stick_data.set_by_mk_data(Decode64(data,3,20));
-
 
319
                String tmp_s="";
-
 
320
                for (int tmp_c=0;tmp_c<10;tmp_c++)
-
 
321
                    tmp_s+="s"+tmp_c+"v"+stick_data.stick[tmp_c]+" ";
304
                lcd_data_count++;
322
                debug.log(tmp_s);
Line 305... Line 323...
305
                break;
323
                break;
306
 
324
 
307
            case 'L':
325
            case 'L':
Line 313... Line 331...
313
                params_data_count++;
331
                params_data_count++;
314
                break;
332
                break;
Line 315... Line 333...
315
 
333
 
316
            default:
334
            default:
-
 
335
                other_data_count++;
-
 
336
                debug.log("got other data:" + (char)data[2] + "=>" + (byte)data[2]);
-
 
337
 
-
 
338
 
-
 
339
                String tmp_str="";
-
 
340
                for (int tmp_i=0;tmp_i<len;tmp_i++)
-
 
341
                    tmp_str+=(char)data[tmp_i];
317
                other_data_count++;
342
                debug.log(tmp_str);
Line 318... Line 343...
318
                break;
343
                break;
Line 367... Line 392...
367
                       {
392
                            {
Line 368... Line 393...
368
 
393
 
369
                           input = reader.read() ;
394
                                input = reader.read() ;
370
                           if (proxy!=null)
395
                                if (proxy!=null)
371
                               proxy.writer.write(input);
396
                                    proxy.writer.write(input);
-
 
397
                                //                              if (input==-1) throw new Exception("test");
-
 
398
                                if (input!=-1)
372
                           if (input==-1) throw new Exception("test");
399
                                    {
373
                           data_set[pos]=input;
400
                                        data_set[pos]=input;
-
 
401
                                        pos++;
Line 374... Line 402...
374
                           pos++;
402
                                    }
Line 375... Line 403...
375
     
403
     
376
                       }
404
                            }
377
 
405
 
378
                           if (proxy!=null)
406
                        if (proxy!=null)
379
                               {
407
                            {
380
                                proxy.writer.write('\r');
408
                                proxy.writer.write('\r');
Line -... Line 409...
-
 
409
                                proxy.writer.write('\n');
381
                                proxy.writer.write('\n');
410
                                proxy.writer.flush();
Line 382... Line 411...
382
                                proxy.writer.flush();
411
                            }
383
                               }
412
 
384
 
413
                        if (pos>5)
385
                    process_data(data_set,pos);
414
                            process_data(data_set,pos);
-
 
415
                   
386
                   
416
                    }
387
                   }
417
                    catch (Exception ex)
Line 388... Line 418...
388
        catch (Exception ex)
418
                        {