8 years ago.

hi, guys.How can I read CANBUS data over the internet, have there ready code or can it help?Thanks.


#include "mbed.h"
 
const uint16_t MSG_ID_1 = 1;
const uint16_t MSG_ID_2 = 2;
// const uint16_t MSG_ID_3 = 3;

Serial      pc(USBTX, USBRX);
DigitalOut  led1(LED1);
DigitalOut  led2(LED2);
DigitalOut  led3(LED3);
CAN         can(p30, p29);
CANMessage msg = CANMessage();                           
   
                           
uint8_t      outputValue;   // 1 byte   
int main()
{
    can.frequency(500000);
    pc.baud(9600);
    msg.len=8;                       
    msg.format=CANStandard;          
    msg.type=CANData; 
    while(1) {
        if(can.read(msg)) {
            led2.write(1);
           
             switch(msg.id) {
             case MSG_ID_1:
           
                led1 = !led1;
                pc.printf("%d", msg.id); pc.printf(" ");
                 for(int i=0 ; i < msg.len; i++){    
                 pc.printf("%d", msg.data[i]); 
                 pc.printf(" ");
                    }
            break;
            case MSG_ID_2:
            led3=!led3;
            pc.printf("%d", msg.id); pc.printf(" ");
            for(int i = 0; i < msg.len; i++){
            if (msg.data[0]>255)  {
              pc.printf("%d", msg.data[0]+255); pc.printf(" ");}
              else {
                 pc.printf("%d", msg.data[i]); pc.printf(" ");
                 }
                    }
            break;
                }
                pc.printf("\r\n");
                wait(0.1);
            
            }
             wait(0.1);
        }
    }


Code that reads the data from the sensors

posted by EKREM KELES 18 Dec 2016

You need to explain what you want a lot better than that if you want any help. You want to read CAN data over the internet? How? Do you want to poll the mbed, have it push it to a server your read, have the mebd act as the server? Broadcast it as UDP data on the LAN? Wired or wireless connection? Which mbed?

posted by Andy A 19 Dec 2016

wired connection.for example 192.168.1.102 I want to read in this ip address.

posted by EKREM KELES 19 Dec 2016

1 Answer

8 years ago.

Hello Ekrem.

I would recommend to visit: https://thingspeak.com/ Also recommended this example: http://www.frank-zhao.com/thingspeak_mbed_tut1/

As you could see... you would need an Ethernet interface code (wired connection). And also an Ethernet Shield. As Andy asked you, it is important that you explain better. Do you have your own server? Could thingspeak fit to your needs? it will be UDP?

Best regards.

/media/uploads/kelesekrem/ekran_al-nt-s-_QmMnTd5.png Thank you. I made internet connections at lpc1768. td- td+ rd- rd+. I currently have internet at lpc1768.192.168.1.102 I enter the ip address and I can not create an interface. Ie how to transfer the can bus data.

posted by EKREM KELES 20 Dec 2016

https://developer.mbed.org/users/nobuki/code/NetRemoteController/

thanks Felicito. I have studied this example and friend is reading sensor data from here. I want to read the can bus data like this friend. I could have run this example. I just need to change the interface. I can not do it because I do not know html coding.

posted by EKREM KELES 20 Dec 2016