7 years, 10 months 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);
        }
    }


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

posted by EKREM KELES 09 Jan 2017

Well you could start by including the ethernet library in your code, there are plenty of examples of that.

Sent over the internet how? TCP or UDP? Acting as a client or a server? You need to answer the questions that were asked last time you posted this question. You said over the internet and then gave a non-routable IP address that isn't valid outside of a local LAN.

posted by Andy A 10 Jan 2017

I do not know much about this Andy. .Ok i want to read the data on this ip.I can not tell you what I understand, you will not understand :)

posted by EKREM KELES 10 Jan 2017
Be the first to answer this question.