• PUDN用户
    了解作者
  • Borland C++
    开发工具
  • 271KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 43
    下载次数
  • 2009-03-25 09:29
    上传日期
微芯的J1939协议栈,是学习地址声明的好代码
200892620511711377.zip
  • J1939
  • Examples.zip
    173.4KB
  • J1939.H
    13KB
  • j1939.cls
    5.5KB
  • J1939.ReadMe.pdf
    89.5KB
  • J1939.C
    34.2KB
  • 新建 文本文档 (2).txt
    2.1KB
内容介绍
微芯的J1939协议栈,是学习地址声明的好代码 比较NAME函数有一个BUG,就是比较时的顺序有问题,应该反过来 signed char CompareName( unsigned char *OtherName ) { unsigned char i; for (i = 0; (i<J1939_DATA_LENGTH) && (OtherName[i] == CA_Name[i]); i++); if (i == J1939_DATA_LENGTH) return 0; else if (CA_Name[i] < OtherName[i] ) return -1; else return 1; } static void J1939_AddressClaimHandling( unsigned char Mode ) { OneMessage.Priority = J1939_CONTROL_PRIORITY; OneMessage.PDUFormat = J1939_PF_ADDRESS_CLAIMED; OneMessage.DestinationAddress = J1939_GLOBAL_ADDRESS; OneMessage.DataLength = J1939_DATA_LENGTH; if (Mode == ADDRESS_CLAIM_TX) goto SendAddressClaim; if (OneMessage.SourceAddress != J1939_Address) return; if (CompareName( OneMessage.Data ) != -1) // Our CA_Name is not less { #if J1939_ARBITRARY_ADDRESS != 0x00 //当地址不能被声明的时候,重新计算一下地址,可以在里面乱写一通,然后重新声明地址 if (CA_RecalculateAddress( &CommandedAddress )) goto SendAddressClaim; #endif // Send Cannot Claim Address message CopyName(); OneMessage.SourceAddress = J1939_NULL_ADDRESS; SET_NETWORK_WINDOW_BITS; SendOneMessage( (J1939_MESSAGE *) &OneMessage ); // Set up filter to receive messages sent to the global address SetAddressFilter( J1939_GLOBAL_ADDRESS ); J1939_Flags.CannotClaimAddress = 1; J1939_Flags.WaitingForAddressClaimContention = 0; return; } SendAddressClaim: CopyName(); OneMessage.SourceAddress = CommandedAddress; SET_NETWORK_WINDOW_BITS; SendOneMessage( (J1939_MESSAGE *) &OneMessage ); if (((CommandedAddress & 0x80) == 0) || // Addresses 0-127 ((CommandedAddress & 0xF8) == 0xF8)) // Addresses 248-253 (254,255 illegal) { J1939_Flags.CannotClaimAddress = 0; J1939_Address = CommandedAddress; // Set up filter to receive messages sent to this address SetAddressFilter( J1939_Address ); } else { // We don't have a proprietary address, so we need to wait. J1939_Flags.WaitingForAddressClaimContention = 1; ContentionWaitTime = 0; } }
评论
    相关推荐
    • J1939_stack-master.zip
      J1939 stack master application
    • CAN_J1939.zip
      J1939协议栈源码,有详细的使用说明,在KEIL C166 (XC2331D)上编译通过。
    • J1939_stack-master.zip
      J1939协议源码,可以在linux环境下运行
    • J1939.zip
      CANbus source code related to CANbus stack development
    • test-can-j1939-master.zip
      J1939 on CAN protocol
    • J1939_STACK_TEST.rar
      基于CANoe CAPL语言编写的程序,模拟直流充电桩节点的上位机,观察BMS与直流充电桩通讯的各项参数
    • J1939协议源代码
      这个J1939的协议是在PIC单片机上实现的,有需要的朋友尽管拿去参考吧
    • ImageJ.rar
      image j条带灰度值分析软件,科研必备
    • ImageJ_v1.8.0.zip
      ImageJ是一款基于 java的,由 National Institutes of Health(NIH)开发的一款功能强大的图像处理软件,在科研中应用极为广泛。最最关键的,这款软件是完完全全免费的!而且前人已经开发出了许许多多,针对不同需求...
    • log4j-api-2.11.1-sources.zip
      log4j-api-2.11.1-sources 的源代码包可以参考使用。