Subversion Repositories HomeAutomation

Rev

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

Rev 1115 Rev 1304
Line 58... Line 58...
58
static char sendbuf[SEND_BUFFER_SIZE+1];
58
static char sendbuf[SEND_BUFFER_SIZE+1];
59
static uint8_t buffpoint;
59
static uint8_t buffpoint;
60
 
60
 
61
#define C2S_START_BYTE 253
61
#define C2S_START_BYTE 253
62
#define C2S_END_BYTE 250
62
#define C2S_END_BYTE 250
-
 
63
#define C2S_PING_BYTE 251
63
 
64
 
64
#if USE_STDCAN == 0
65
#if USE_STDCAN == 0
65
volatile Can_Message_t rxMsg; // Message storage
66
volatile Can_Message_t rxMsg; // Message storage
66
volatile uint8_t rxMsgFull;   // Synchronization flag
67
volatile uint8_t rxMsgFull;   // Synchronization flag
67
#endif
68
#endif
Line 299... Line 300...
299
                                prgremoteip[i]=buf[IP_SRC_P +i];
300
                                prgremoteip[i]=buf[IP_SRC_P +i];
300
                                i++;
301
                                i++;
301
                            }
302
                            }
302
                            gotcan2serserver = 1;
303
                            gotcan2serserver = 1;
303
 
304
 
304
                            if ((buf[UDP_DATA_P]==C2S_START_BYTE) && (buf[UDP_DATA_P+16]==C2S_END_BYTE) && (payloadlen==17)) {
305
                            if ((buf[UDP_DATA_P]==C2S_START_BYTE) && (buf[UDP_DATA_P+16]==C2S_END_BYTE) && (payloadlen==17))
-
 
306
                            {
305
#if USE_STDCAN == 0
307
#if USE_STDCAN == 0
306
                                Can_Message_t cm;
308
                                Can_Message_t cm;
307
                                //cm.Id = 0;
309
                                //cm.Id = 0;
308
                                cm.DataLength = buf[UDP_DATA_P+7];
310
                                cm.DataLength = buf[UDP_DATA_P+7];
309
                                cm.RemoteFlag = buf[UDP_DATA_P+6];
311
                                cm.RemoteFlag = buf[UDP_DATA_P+6];
310
                                cm.ExtendedFlag = buf[UDP_DATA_P+5];
312
                                cm.ExtendedFlag = buf[UDP_DATA_P+5];
311
                                cm.Id = (uint32_t)buf[UDP_DATA_P+1] + ((uint32_t)buf[UDP_DATA_P+2] << 8) + ((uint32_t)buf[UDP_DATA_P+3] << 16) + ((uint32_t)buf[UDP_DATA_P+4] << 24);
313
                                cm.Id = (uint32_t)buf[UDP_DATA_P+1] + ((uint32_t)buf[UDP_DATA_P+2] << 8) +
-
 
314
                                        ((uint32_t)buf[UDP_DATA_P+3] << 16) + ((uint32_t)buf[UDP_DATA_P+4] << 24);
312
                                uint8_t i;
315
                                uint8_t i;
313
                                for (i = 0; i < cm.DataLength; i++) {
316
                                for (i = 0; i < cm.DataLength; i++) {
314
                                    cm.Data.bytes[i] = buf[UDP_DATA_P+8+i];
317
                                    cm.Data.bytes[i] = buf[UDP_DATA_P+8+i];
315
                                }
318
                                }
316
                                Can_Send(&cm);
319
                                Can_Send(&cm);
317
#else
320
#else
318
                                static StdCan_Msg_t cm;
321
                                static StdCan_Msg_t cm;
319
                                //cm.Id = 0;
322
                                //cm.Id = 0;
320
                                cm.Length = buf[UDP_DATA_P+7];
323
                                cm.Length = buf[UDP_DATA_P+7];
321
                                cm.Id = (uint32_t)buf[UDP_DATA_P+1] + ((uint32_t)buf[UDP_DATA_P+2] << 8) + ((uint32_t)buf[UDP_DATA_P+3] << 16) + ((uint32_t)buf[UDP_DATA_P+4] << 24);
324
                                cm.Id = (uint32_t)buf[UDP_DATA_P+1] + ((uint32_t)buf[UDP_DATA_P+2] << 8) +
-
 
325
                                        ((uint32_t)buf[UDP_DATA_P+3] << 16) + ((uint32_t)buf[UDP_DATA_P+4] << 24);
322
                                uint8_t i;
326
                                uint8_t i;
323
                                for (i = 0; i < cm.Length; i++) {
327
                                for (i = 0; i < cm.Length; i++) {
324
                                    cm.Data[i] = buf[UDP_DATA_P+8+i];
328
                                    cm.Data[i] = buf[UDP_DATA_P+8+i];
325
                                }
329
                                }
326
                                StdCan_Put(&cm);
330
                                StdCan_Put(&cm);
Line 331... Line 335...
331
                                    for (i=0; i<cm.DataLength; i++) {
335
                                    for (i=0; i<cm.DataLength; i++) {
332
                                        printf("%x ", cm.Data.bytes[i]);
336
                                        printf("%x ", cm.Data.bytes[i]);
333
                                    }
337
                                    }
334
                                    printf("}\n");
338
                                    printf("}\n");
335
                                }*/
339
                                }*/
-
 
340
                            }
-
 
341
                            else if ((buf[UDP_DATA_P]==C2S_PING_BYTE) && (payloadlen==1))
-
 
342
                            {
-
 
343
                                char sendbuf3[1];
-
 
344
                                sendbuf3[0] = C2S_PING_BYTE;
-
 
345
               
-
 
346
#ifndef ENC28J60_USART_SPI_MODE 
-
 
347
                                cli();
-
 
348
#endif
-
 
349
                                send_udp(buf, sendbuf3, 1, rmCan2SerPrt, prgremotemac, prgremoteip);
-
 
350
#ifndef ENC28J60_USART_SPI_MODE 
-
 
351
                                sei();
-
 
352
#endif
336
                            }
353
                            }
337
                        //om port 1200 (dumparporten) 
354
                        //om port 1200 (dumparporten) 
338
                        } /*else if ((buf[UDP_DST_PORT_H_P]==((locDumperPrt>>8) & 0xff)) && (buf[UDP_DST_PORT_L_P] == (locDumperPrt & 0xff))) {
355
                        } /*else if ((buf[UDP_DST_PORT_H_P]==((locDumperPrt>>8) & 0xff)) && (buf[UDP_DST_PORT_L_P] == (locDumperPrt & 0xff))) {
339
                            if (gotdumpserver == 0) {
356
                            if (gotdumpserver == 0) {
340
                                while(i<6){
357
                                while(i<6){