福彩3D走势图

技术天地

支持CAN FD的扩展模块介绍作者:黄志超    发布时间:2020-5-27 13:57:33    被阅览数:次

  随着现在工控领域技术的发展,传输的数据量越来越多, CAN总线在传输速率和带宽渐渐不能满足现场的需求。为了解决这个问题,BOSCH公司推出了CAN FD(CAN with Flexible Data rate)协议,该协议可以支持更高的波特率和更长的数据位,最高波特率可达8Mbit/s,支持最长数据位为64byte,并且可以兼容传统的CAN 2.0B协议。为了在英创Linux工控主板上支持CAN FD,满足客户的需求,英创公司基于SBC8XX系列工控应用底板,设计了扩展模块ETA703。


eta703侧面.png

ETA703模块


  ETA703通过SPI总线扩展出一路支持CAN FD的CAN总线,同时将主板的串口隔离后分别转换为RS232和RS485,并将主板带有的2路CAN总线也经过隔离后引出,因此模块上一共包含3路can、3路RS485和1路RS232:


ETA703工控通讯接口接口数量简要说明
CAN-FD高速现场总线1 8Mbps最高波特率,与CAN2.0B兼容
CAN-2.0B总线2 波特率: 50kbps - 1Mbps
RS4853 自动方向切换
RS2321 3线制


  YINGCHUANGGONGSIYIJINGDIAOSHIHAOLEETA703DEQUDONG,YONGHUZAISHIYONGSHIDIAOYONGmodprobe eta703MINGLINGJIUNENGGOUJIAZAIDUIYINGDEQUDONGWENJIAN。MUQIANNENGGOUZHICHIETA703KUOZHANMOKUAIDEZHUBANWEIESM6800H/E,ESM6802HEESM7000,YINWEICAN FDSHIBIJIAOXINDEGONGNENG,XUYAOZHEIJIKUANZHUBANSHIYONGDEJIAOGAOBANBENDEJIAOCHAGONGJULIANCAINENGGOUZHICHI。


福彩3D走势图  QUDONGJIAZAICHENGGONGHOUXITONGHUISHENGCHENGXINDECANSHEBEI,YINWEIESMARCXILIEZHUBANDOUBANZAILE2LUCANZONGXIAN(can0HEcan1),SUOYIJIAZAIQUDONGHOUSHENGCHENGDESHEBEIWEIcan2,KEYISHIYONGMINGLINGifconfig –aLAICHAKAN。


  GUANYUETA703GENGJIAJUTIDECANSHUSHUOMINGKEYICANKAOETA703DESHUJUSHOUCE。ZHEILIZHUYAOJIESHAOGUANYUCAN FDDEXIANGGUANGAINIANHECHENGXUJIEKOU。CAN FDDEQUANCHENGWEICAN with Flexible Data rate,XIANGDUIYUCHUANTONGDECANZONGXIANXIEYI,ZHUYAOYOULIANGDIANBIANHUA:


福彩3D走势图  DIYIDIANCONGZIMIANSHANGJIUNENGGOUKANCHULAI,JICHUANSHUSULVSHIKEBIANDE,ZUIGAOKEDA8Mbit/s。


  DIERDIANSHIXIANGBICHUANTONGCANZONGXIANDE8byteSHUJUWEI,CAN FDXIEYIZUIZHANGKEYIZHICHI64byteSHUJUWEI。


  WOMENKEYIJIANGCAN FDKANZUOSHICHUANTONGCAN 2.0BXIEYIDESHENGJIBANBEN,BINGQIESHIXIANGXIAJIANRONGDE,JINENGGOUTONGSHIZHICHICAN 2.0BXIEYI。SUOYISHIYONGYUANLAIYINGCHUANGGONGSITIGONGDECANZONGXIANLICHENG(test_socketcan)JIUNENGGOUZAIETA703SHANGJINXINGZHENGCHANGDETONGXUN,ZHISHIMEIYOUQIYONGCAN FDDEGONGNENGERYI,GUANYUCAN FDXIEYIGENGJIAXIANGXIDEJIESHAOKEYICANKAOWANGZHAN:。


  JIEXIALAIWOMENJIESHAORUHETONGGUOCHENGXUQIYONGCAN FDXIEYIJINXINGTONGXUN。QISHILinuxXITONGSHIYONGDEsocketcanJIEKOUYIJINGHENHAODEZHICHILECAN FD,BINGQIETONGSHINENGGOUJIANRONGCAN 2.0BXIEYI。SHOUXIANLAIKANZAI<linux/can.h>TOUWENJIANZHONGDUIYUCANHECANFDSHUJUZHENDEJIEGOUTIDINGYI:



struct can_frame {

       canid_t can_id/* 32 bit CAN_ID + EFF/RTR/ERR flags */

       __u8    can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */

       __u8    __pad;   /* padding */

       __u8    __res0/* reserved / padding */

       __u8    __res1/* reserved / padding */

       __u8    data[CAN_MAX_DLEN] __attribute__((aligned(8)));

};


  SHANGMIANSHIDUICANSHUJUZHENDEDINGYI,HEXIAMIANCAN FDSHUJUZHENDEDINGYIDUIBI,KEYIFAXIANSHIJIANRONGDE,QUBIEZHIZAIYUSHUJUWEIDEZHANGDUSHANGMIAN:



struct canfd_frame {

       canid_t can_id/* 32 bit CAN_ID + EFF/RTR/ERR flags */

       __u8    len;     /* frame payload length in byte */

       __u8    flags;   /* additional flags for CAN FD */

       __u8    __res0/* reserved / padding */

       __u8    __res1/* reserved / padding */

       __u8    data[CANFD_MAX_DLEN] __attribute__((aligned(8)));

};


  GUANYUSHUJUWEIDEZHANGDU,GENJUQIANMIANDEJIESHAOYINGGAINENGGOULEJIEDAOCAN FDZUIZHANGZHICHI64byteDESHUJUWEI,ZAITOUWENJIANZHONGYOURUXIADINGYI:



/* CAN payload length and DLC definitions according to ISO 11898-1 */

#define CAN_MAX_DLC 8

#define CAN_MAX_DLEN 8

 

/* CAN FD payload length and DLC definitions according to ISO 11898-7 */

#define CANFD_MAX_DLC 15

#define CANFD_MAX_DLEN 64


福彩3D走势图  QIYONGCAN FDJUTIMINGLINGWEIip link set can2 up type can bitrate 1000000 dbitrate 2000000 fd on restart-ms 100,KEYIKANDAOSHIZAIYUANLAISHINENGCANZONGXIANMINGLINGDEJICHUSHANGZENGJIALECAN FDDEBOTELVDESHEZHI。TONGSHIZAICHENGXUZHONGYEXUYAODIAOYONGioctlLAISHINENGCAN FD,JUTIDAIMARUXIA:



/* try to switch the socket into CAN FD mode */

canfd_on = 1;

setsockopt(s, SOL_CAN_RAW, CAN_RAW_FD_FRAMES, &canfd_on, sizeof(canfd_on));


福彩3D走势图  ZAISHINENGLECAN FDXIEYIHOU,SHUJUTONGXUNDEBUFENSHIYONGDEHANSHUHEBIAOZHUNDECANTONGXUNSHIXIANGTONGDE,DOUSHISHIYONGwriteHErecvHANSHU,QUDONGHUIGENJUCHUANSHUDEZHENDEZHANGDU,ZIDONGPANDUANSHIFOUWEICAN FDSHUJUZHEN。SUOYIKEHUZAIBIANXIECHENGXUDESHIHOU,ZHIXUYAOZHUYIYIXIATIANRUDECHUANSHUSHUJUZHANGDUJIKE,ZHEILIKEYILIYONGTOUWENJIANZHONGDEHONGDINGYI:



#define CAN_MTU           (sizeof(struct can_frame))

#define CANFD_MTU       (sizeof(struct canfd_frame))


  FASONGCAN FDSHUJUDEJUTIDAIMARUXIA:



struct canfd_frame   frame;

frame.len = 64;

nbytes = write(s, &frame, CANFD_MTU);


福彩3D走势图  RUGUOJIANGframe.lenDEZHIGAIWEI8,writeHANSHUZHONGDEZHANGDUGAIWEICAN_MTU,QUDONGJIUZIDONGQIEHUANCHENGCAN 2.0BXIEYIJINXINGFASONG。TONGYANGDEZAIJIESHOUSHUJUDESHIHOU,KEYITONGGUOrecvHANSHUDEFANHUIZHILAIPANDUAN,JUTIDAIMARUXIA:



nbytes = recv(can_sock, &frame, CANFD_MTU, 0 );

if (nbytes < 0)

{

       perror("can raw socket read");

       break;

}

if ((size_t)nbytes == CAN_MTU) {

       maxdlen = CAN_MAX_DLEN;

}

else if ((size_t)nbytes == CANFD_MTU) {

       maxdlen = CANFD_MAX_DLEN;

}

else {

       fprintf(stderr, "read: incomplete CAN frame\n");

       return 1;

}


  CONGSHANGMIANDEDAIMAKEYIKANCHUCAN FDDEBIANCHENGSHIFENJIANDAN,socketcanTIGONGDEJIEKOUWANMEIDEJIANRONGLECAN 2.0BHECAN FD,ZHIXUYAOZAIYUANLAIBIAOZHUNCANZONGXIANDELICHENGZHONGZENGJIADUICAN FDDESHINENGJIUKEYILE,ZAISHUJUCHUANSHUSHIHOU,GENJUSHUJUZHENZHANGDUJIUNENGPANDUANCHULEIXING,RANHOUZUOCHUDUIYINGDECHULI。


  GANXINGQUDEKEHUKEYIHEYINGCHUANGDEGONGCHENGSHILIANXI,SUOQUWANZHENGDELICHENGDAIMA。

Go Top