shenlan.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  1. /* Generated by DBCC, see <https://github.com/howerj/dbcc> */
  2. #include "shenlan.h"
  3. #include <inttypes.h>
  4. #include <assert.h>
  5. #define UNUSED(X) ((void)(X))
  6. static inline uint64_t reverse_byte_order(uint64_t x) {
  7. x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32;
  8. x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16;
  9. x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8;
  10. return x;
  11. }
  12. static inline int print_helper(int r, int print_return_value) {
  13. return ((r >= 0) && (print_return_value >= 0)) ? r + print_return_value : -1;
  14. }
  15. static int pack_can_0x144_ECU_144(can_obj_shenlan_h_t *o, uint64_t *data) {
  16. assert(o);
  17. assert(data);
  18. register uint64_t x;
  19. register uint64_t m = 0;
  20. /* ACC_LatAngReq: start-bit 4, length 14, endianess motorola, scaling 0.1, offset -720 */
  21. x = ((uint16_t)(o->can_0x144_ECU_144.ACC_LatAngReq)) & 0x3fff;
  22. x <<= 47;
  23. m |= x;
  24. /* ACC_MotorTorqueMaxLimitRequest: start-bit 21, length 11, endianess motorola, scaling 0.02, offset -20.48 */
  25. x = ((uint16_t)(o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest)) & 0x7ff;
  26. x <<= 35;
  27. m |= x;
  28. /* ACC_MotorTorqueMinLimitRequest: start-bit 26, length 11, endianess motorola, scaling 0.02, offset -20.48 */
  29. x = ((uint16_t)(o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest)) & 0x7ff;
  30. x <<= 24;
  31. m |= x;
  32. /* ADS_Reqmode: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
  33. x = ((uint8_t)(o->can_0x144_ECU_144.ADS_Reqmode)) & 0x7;
  34. x <<= 61;
  35. m |= x;
  36. /* ACC_ADCReqType: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
  37. x = ((uint8_t)(o->can_0x144_ECU_144.ACC_ADCReqType)) & 0x3;
  38. x <<= 22;
  39. m |= x;
  40. /* ACC_LatAngReqActive: start-bit 22, length 1, endianess motorola, scaling 1, offset 0 */
  41. x = ((uint8_t)(o->can_0x144_ECU_144.ACC_LatAngReqActive)) & 0x1;
  42. x <<= 46;
  43. m |= x;
  44. *data = reverse_byte_order(m);
  45. o->can_0x144_ECU_144_tx = 1;
  46. return 0;
  47. }
  48. static int unpack_can_0x144_ECU_144(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  49. assert(o);
  50. assert(dlc <= 8);
  51. register uint64_t x;
  52. register uint64_t m = reverse_byte_order(data);
  53. if (dlc < 8)
  54. return -1;
  55. /* ACC_LatAngReq: start-bit 4, length 14, endianess motorola, scaling 0.1, offset -720 */
  56. x = (m >> 47) & 0x3fff;
  57. o->can_0x144_ECU_144.ACC_LatAngReq = x;
  58. /* ACC_MotorTorqueMaxLimitRequest: start-bit 21, length 11, endianess motorola, scaling 0.02, offset -20.48 */
  59. x = (m >> 35) & 0x7ff;
  60. o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest = x;
  61. /* ACC_MotorTorqueMinLimitRequest: start-bit 26, length 11, endianess motorola, scaling 0.02, offset -20.48 */
  62. x = (m >> 24) & 0x7ff;
  63. o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest = x;
  64. /* ADS_Reqmode: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
  65. x = (m >> 61) & 0x7;
  66. o->can_0x144_ECU_144.ADS_Reqmode = x;
  67. /* ACC_ADCReqType: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
  68. x = (m >> 22) & 0x3;
  69. o->can_0x144_ECU_144.ACC_ADCReqType = x;
  70. /* ACC_LatAngReqActive: start-bit 22, length 1, endianess motorola, scaling 1, offset 0 */
  71. x = (m >> 46) & 0x1;
  72. o->can_0x144_ECU_144.ACC_LatAngReqActive = x;
  73. o->can_0x144_ECU_144_rx = 1;
  74. o->can_0x144_ECU_144_time_stamp_rx = time_stamp;
  75. return 0;
  76. }
  77. int decode_can_0x144_ACC_LatAngReq(const can_obj_shenlan_h_t *o, double *out) {
  78. assert(o);
  79. assert(out);
  80. double rval = (double)(o->can_0x144_ECU_144.ACC_LatAngReq);
  81. rval *= 0.1;
  82. rval += -720;
  83. if (rval <= 720) {
  84. *out = rval;
  85. return 0;
  86. } else {
  87. *out = (double)0;
  88. return -1;
  89. }
  90. }
  91. int encode_can_0x144_ACC_LatAngReq(can_obj_shenlan_h_t *o, double in) {
  92. assert(o);
  93. o->can_0x144_ECU_144.ACC_LatAngReq = 0;
  94. if (in > 720)
  95. return -1;
  96. in += 720;
  97. in *= 10;
  98. o->can_0x144_ECU_144.ACC_LatAngReq = in;
  99. return 0;
  100. }
  101. int decode_can_0x144_ACC_MotorTorqueMaxLimitRequest(const can_obj_shenlan_h_t *o, double *out) {
  102. assert(o);
  103. assert(out);
  104. double rval = (double)(o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest);
  105. rval *= 0.02;
  106. rval += -20.48;
  107. if (rval <= 20.44) {
  108. *out = rval;
  109. return 0;
  110. } else {
  111. *out = (double)0;
  112. return -1;
  113. }
  114. }
  115. int encode_can_0x144_ACC_MotorTorqueMaxLimitRequest(can_obj_shenlan_h_t *o, double in) {
  116. assert(o);
  117. o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest = 0;
  118. if (in > 20.44)
  119. return -1;
  120. in += 20.48;
  121. in *= 50;
  122. o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest = in;
  123. return 0;
  124. }
  125. int decode_can_0x144_ACC_MotorTorqueMinLimitRequest(const can_obj_shenlan_h_t *o, double *out) {
  126. assert(o);
  127. assert(out);
  128. double rval = (double)(o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest);
  129. rval *= 0.02;
  130. rval += -20.48;
  131. if (rval <= 20.44) {
  132. *out = rval;
  133. return 0;
  134. } else {
  135. *out = (double)0;
  136. return -1;
  137. }
  138. }
  139. int encode_can_0x144_ACC_MotorTorqueMinLimitRequest(can_obj_shenlan_h_t *o, double in) {
  140. assert(o);
  141. o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest = 0;
  142. if (in > 20.44)
  143. return -1;
  144. in += 20.48;
  145. in *= 50;
  146. o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest = in;
  147. return 0;
  148. }
  149. int decode_can_0x144_ADS_Reqmode(const can_obj_shenlan_h_t *o, uint8_t *out) {
  150. assert(o);
  151. assert(out);
  152. uint8_t rval = (uint8_t)(o->can_0x144_ECU_144.ADS_Reqmode);
  153. *out = rval;
  154. return 0;
  155. }
  156. int encode_can_0x144_ADS_Reqmode(can_obj_shenlan_h_t *o, uint8_t in) {
  157. assert(o);
  158. o->can_0x144_ECU_144.ADS_Reqmode = in;
  159. return 0;
  160. }
  161. int decode_can_0x144_ACC_ADCReqType(const can_obj_shenlan_h_t *o, uint8_t *out) {
  162. assert(o);
  163. assert(out);
  164. uint8_t rval = (uint8_t)(o->can_0x144_ECU_144.ACC_ADCReqType);
  165. *out = rval;
  166. return 0;
  167. }
  168. int encode_can_0x144_ACC_ADCReqType(can_obj_shenlan_h_t *o, uint8_t in) {
  169. assert(o);
  170. o->can_0x144_ECU_144.ACC_ADCReqType = in;
  171. return 0;
  172. }
  173. int decode_can_0x144_ACC_LatAngReqActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
  174. assert(o);
  175. assert(out);
  176. uint8_t rval = (uint8_t)(o->can_0x144_ECU_144.ACC_LatAngReqActive);
  177. *out = rval;
  178. return 0;
  179. }
  180. int encode_can_0x144_ACC_LatAngReqActive(can_obj_shenlan_h_t *o, uint8_t in) {
  181. assert(o);
  182. o->can_0x144_ECU_144.ACC_LatAngReqActive = in;
  183. return 0;
  184. }
  185. int print_can_0x144_ECU_144(const can_obj_shenlan_h_t *o) {
  186. assert(o);
  187. int r = 0;
  188. double ACC_LatAngReq = 0.0;
  189. decode_can_0x144_ACC_LatAngReq(o,&ACC_LatAngReq);
  190. printf("\tACC_LatAngReq = %f\r\n", ACC_LatAngReq);
  191. double ACC_MotorTorqueMaxLimitRequest = 0.0;
  192. decode_can_0x144_ACC_MotorTorqueMaxLimitRequest(o,&ACC_MotorTorqueMaxLimitRequest);
  193. printf("\tACC_MotorTorqueMaxLimitRequest = %f\r\n", ACC_MotorTorqueMaxLimitRequest);
  194. double ACC_MotorTorqueMinLimitRequest = 0.0;
  195. decode_can_0x144_ACC_MotorTorqueMinLimitRequest(o,&ACC_MotorTorqueMinLimitRequest);
  196. printf("\tACC_MotorTorqueMinLimitRequest = %f\r\n", ACC_MotorTorqueMinLimitRequest);
  197. printf("\tADS_Reqmode = %d\r\n", (o->can_0x144_ECU_144.ADS_Reqmode));
  198. printf("\tACC_ADCReqType = %d\r\n", (o->can_0x144_ECU_144.ACC_ADCReqType));
  199. printf("\tACC_LatAngReqActive = %d\r\n", (o->can_0x144_ECU_144.ACC_LatAngReqActive));
  200. return r;
  201. }
  202. static int pack_can_0x147_ADC_147(can_obj_shenlan_h_t *o, uint64_t *data) {
  203. assert(o);
  204. assert(data);
  205. register uint64_t x;
  206. register uint64_t m = 0;
  207. /* EpsSasSteerAg: start-bit 9, length 16, endianess motorola, scaling 0.1, offset 0 */
  208. x = ((uint16_t)(o->can_0x147_ADC_147.EpsSasSteerAg)) & 0xffff;
  209. x <<= 34;
  210. m |= x;
  211. /* EPS_Pinionang: start-bit 7, length 14, endianess motorola, scaling 0.1, offset -720 */
  212. x = ((uint16_t)(o->can_0x147_ADC_147.EPS_Pinionang)) & 0x3fff;
  213. x <<= 50;
  214. m |= x;
  215. /* EspVehSpd: start-bit 41, length 13, endianess motorola, scaling 0.05625, offset 0 */
  216. x = ((uint16_t)(o->can_0x147_ADC_147.EspVehSpd)) & 0x1fff;
  217. x <<= 5;
  218. m |= x;
  219. /* EpsSteerAgRate: start-bit 24, length 8, endianess motorola, scaling 4, offset 0 */
  220. x = ((uint8_t)(o->can_0x147_ADC_147.EpsSteerAgRate)) & 0xff;
  221. x <<= 25;
  222. m |= x;
  223. /* EPS_ADS_Abortfeedback: start-bit 45, length 4, endianess motorola, scaling 1, offset 0 */
  224. x = ((uint8_t)(o->can_0x147_ADC_147.EPS_ADS_Abortfeedback)) & 0xf;
  225. x <<= 18;
  226. m |= x;
  227. /* EPS_LatCtrlAvailabilityStatus: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
  228. x = ((uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus)) & 0x3;
  229. x <<= 22;
  230. m |= x;
  231. /* EpsSasSteerAgVld: start-bit 25, length 1, endianess motorola, scaling 1, offset 0 */
  232. x = ((uint8_t)(o->can_0x147_ADC_147.EpsSasSteerAgVld)) & 0x1;
  233. x <<= 33;
  234. m |= x;
  235. /* EPS_LatCtrlActive: start-bit 32, length 1, endianess motorola, scaling 1, offset 0 */
  236. x = ((uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlActive)) & 0x1;
  237. x <<= 24;
  238. m |= x;
  239. /* EspVehSpdVld: start-bit 60, length 1, endianess motorola, scaling 1, offset 0 */
  240. x = ((uint8_t)(o->can_0x147_ADC_147.EspVehSpdVld)) & 0x1;
  241. x <<= 4;
  242. m |= x;
  243. *data = reverse_byte_order(m);
  244. o->can_0x147_ADC_147_tx = 1;
  245. return 0;
  246. }
  247. static int unpack_can_0x147_ADC_147(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  248. assert(o);
  249. assert(dlc <= 8);
  250. register uint64_t x;
  251. register uint64_t m = reverse_byte_order(data);
  252. if (dlc < 8)
  253. return -1;
  254. /* EpsSasSteerAg: start-bit 9, length 16, endianess motorola, scaling 0.1, offset 0 */
  255. x = (m >> 34) & 0xffff;
  256. o->can_0x147_ADC_147.EpsSasSteerAg = x;
  257. /* EPS_Pinionang: start-bit 7, length 14, endianess motorola, scaling 0.1, offset -720 */
  258. x = (m >> 50) & 0x3fff;
  259. o->can_0x147_ADC_147.EPS_Pinionang = x;
  260. /* EspVehSpd: start-bit 41, length 13, endianess motorola, scaling 0.05625, offset 0 */
  261. x = (m >> 5) & 0x1fff;
  262. o->can_0x147_ADC_147.EspVehSpd = x;
  263. /* EpsSteerAgRate: start-bit 24, length 8, endianess motorola, scaling 4, offset 0 */
  264. x = (m >> 25) & 0xff;
  265. o->can_0x147_ADC_147.EpsSteerAgRate = x;
  266. /* EPS_ADS_Abortfeedback: start-bit 45, length 4, endianess motorola, scaling 1, offset 0 */
  267. x = (m >> 18) & 0xf;
  268. o->can_0x147_ADC_147.EPS_ADS_Abortfeedback = x;
  269. /* EPS_LatCtrlAvailabilityStatus: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
  270. x = (m >> 22) & 0x3;
  271. o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus = x;
  272. /* EpsSasSteerAgVld: start-bit 25, length 1, endianess motorola, scaling 1, offset 0 */
  273. x = (m >> 33) & 0x1;
  274. o->can_0x147_ADC_147.EpsSasSteerAgVld = x;
  275. /* EPS_LatCtrlActive: start-bit 32, length 1, endianess motorola, scaling 1, offset 0 */
  276. x = (m >> 24) & 0x1;
  277. o->can_0x147_ADC_147.EPS_LatCtrlActive = x;
  278. /* EspVehSpdVld: start-bit 60, length 1, endianess motorola, scaling 1, offset 0 */
  279. x = (m >> 4) & 0x1;
  280. o->can_0x147_ADC_147.EspVehSpdVld = x;
  281. o->can_0x147_ADC_147_rx = 1;
  282. o->can_0x147_ADC_147_time_stamp_rx = time_stamp;
  283. return 0;
  284. }
  285. int decode_can_0x147_EpsSasSteerAg(const can_obj_shenlan_h_t *o, double *out) {
  286. assert(o);
  287. assert(out);
  288. double rval = (double)(o->can_0x147_ADC_147.EpsSasSteerAg);
  289. rval *= 0.1;
  290. if ((rval >= -780) && (rval <= 780)) {
  291. *out = rval;
  292. return 0;
  293. } else {
  294. *out = (double)0;
  295. return -1;
  296. }
  297. }
  298. int encode_can_0x147_EpsSasSteerAg(can_obj_shenlan_h_t *o, double in) {
  299. assert(o);
  300. o->can_0x147_ADC_147.EpsSasSteerAg = 0;
  301. if (in < -780)
  302. return -1;
  303. if (in > 780)
  304. return -1;
  305. in *= 10;
  306. o->can_0x147_ADC_147.EpsSasSteerAg = in;
  307. return 0;
  308. }
  309. int decode_can_0x147_EPS_Pinionang(const can_obj_shenlan_h_t *o, double *out) {
  310. assert(o);
  311. assert(out);
  312. double rval = (double)(o->can_0x147_ADC_147.EPS_Pinionang);
  313. rval *= 0.1;
  314. rval += -720;
  315. if (rval <= 720) {
  316. *out = rval;
  317. return 0;
  318. } else {
  319. *out = (double)0;
  320. return -1;
  321. }
  322. }
  323. int encode_can_0x147_EPS_Pinionang(can_obj_shenlan_h_t *o, double in) {
  324. assert(o);
  325. o->can_0x147_ADC_147.EPS_Pinionang = 0;
  326. if (in > 720)
  327. return -1;
  328. in += 720;
  329. in *= 10;
  330. o->can_0x147_ADC_147.EPS_Pinionang = in;
  331. return 0;
  332. }
  333. int decode_can_0x147_EspVehSpd(const can_obj_shenlan_h_t *o, double *out) {
  334. assert(o);
  335. assert(out);
  336. double rval = (double)(o->can_0x147_ADC_147.EspVehSpd);
  337. rval *= 0.05625;
  338. if (rval <= 460.744) {
  339. *out = rval;
  340. return 0;
  341. } else {
  342. *out = (double)0;
  343. return -1;
  344. }
  345. }
  346. int encode_can_0x147_EspVehSpd(can_obj_shenlan_h_t *o, double in) {
  347. assert(o);
  348. o->can_0x147_ADC_147.EspVehSpd = 0;
  349. if (in > 460.744)
  350. return -1;
  351. in *= 17.7778;
  352. o->can_0x147_ADC_147.EspVehSpd = in;
  353. return 0;
  354. }
  355. int decode_can_0x147_EpsSteerAgRate(const can_obj_shenlan_h_t *o, double *out) {
  356. assert(o);
  357. assert(out);
  358. double rval = (double)(o->can_0x147_ADC_147.EpsSteerAgRate);
  359. rval *= 4;
  360. *out = rval;
  361. return 0;
  362. }
  363. int encode_can_0x147_EpsSteerAgRate(can_obj_shenlan_h_t *o, double in) {
  364. assert(o);
  365. in *= 0.25;
  366. o->can_0x147_ADC_147.EpsSteerAgRate = in;
  367. return 0;
  368. }
  369. int decode_can_0x147_EPS_ADS_Abortfeedback(const can_obj_shenlan_h_t *o, uint8_t *out) {
  370. assert(o);
  371. assert(out);
  372. uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EPS_ADS_Abortfeedback);
  373. *out = rval;
  374. return 0;
  375. }
  376. int encode_can_0x147_EPS_ADS_Abortfeedback(can_obj_shenlan_h_t *o, uint8_t in) {
  377. assert(o);
  378. o->can_0x147_ADC_147.EPS_ADS_Abortfeedback = in;
  379. return 0;
  380. }
  381. int decode_can_0x147_EPS_LatCtrlAvailabilityStatus(const can_obj_shenlan_h_t *o, uint8_t *out) {
  382. assert(o);
  383. assert(out);
  384. uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus);
  385. *out = rval;
  386. return 0;
  387. }
  388. int encode_can_0x147_EPS_LatCtrlAvailabilityStatus(can_obj_shenlan_h_t *o, uint8_t in) {
  389. assert(o);
  390. o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus = in;
  391. return 0;
  392. }
  393. int decode_can_0x147_EpsSasSteerAgVld(const can_obj_shenlan_h_t *o, uint8_t *out) {
  394. assert(o);
  395. assert(out);
  396. uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EpsSasSteerAgVld);
  397. *out = rval;
  398. return 0;
  399. }
  400. int encode_can_0x147_EpsSasSteerAgVld(can_obj_shenlan_h_t *o, uint8_t in) {
  401. assert(o);
  402. o->can_0x147_ADC_147.EpsSasSteerAgVld = in;
  403. return 0;
  404. }
  405. int decode_can_0x147_EPS_LatCtrlActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
  406. assert(o);
  407. assert(out);
  408. uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlActive);
  409. *out = rval;
  410. return 0;
  411. }
  412. int encode_can_0x147_EPS_LatCtrlActive(can_obj_shenlan_h_t *o, uint8_t in) {
  413. assert(o);
  414. o->can_0x147_ADC_147.EPS_LatCtrlActive = in;
  415. return 0;
  416. }
  417. int decode_can_0x147_EspVehSpdVld(const can_obj_shenlan_h_t *o, uint8_t *out) {
  418. assert(o);
  419. assert(out);
  420. uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EspVehSpdVld);
  421. *out = rval;
  422. return 0;
  423. }
  424. int encode_can_0x147_EspVehSpdVld(can_obj_shenlan_h_t *o, uint8_t in) {
  425. assert(o);
  426. o->can_0x147_ADC_147.EspVehSpdVld = in;
  427. return 0;
  428. }
  429. int print_can_0x147_ADC_147(const can_obj_shenlan_h_t *o) {
  430. assert(o);
  431. int r = 0;
  432. double EpsSasSteerAg = 0.0;
  433. decode_can_0x147_EpsSasSteerAg(o,&EpsSasSteerAg);
  434. printf("\tEpsSasSteerAg = %f\r\n", EpsSasSteerAg);
  435. double EPS_Pinionang = 0.0;
  436. decode_can_0x147_EPS_Pinionang(o,&EPS_Pinionang);
  437. printf("\tEPS_Pinionang = %f\r\n", EPS_Pinionang);
  438. double EspVehSpd = 0.0;
  439. decode_can_0x147_EspVehSpd(o,&EspVehSpd);
  440. printf("\tEspVehSpd = %f\r\n", EspVehSpd);
  441. double EpsSteerAgRate = 0.0;
  442. decode_can_0x147_EpsSteerAgRate(o,&EpsSteerAgRate);
  443. printf("\tEpsSteerAgRate = %f\r\n", EpsSteerAgRate);
  444. printf("\tEPS_ADS_Abortfeedback = %d\r\n", (o->can_0x147_ADC_147.EPS_ADS_Abortfeedback));
  445. printf("\tEPS_LatCtrlAvailabilityStatus = %d\r\n", (o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus));
  446. printf("\tEpsSasSteerAgVld = %d\r\n", (o->can_0x147_ADC_147.EpsSasSteerAgVld));
  447. printf("\tEPS_LatCtrlActive = %d\r\n", (o->can_0x147_ADC_147.EPS_LatCtrlActive));
  448. printf("\tEspVehSpdVld = %d\r\n", (o->can_0x147_ADC_147.EspVehSpdVld));
  449. return r;
  450. }
  451. static int pack_can_0x14a_ADC_14A(can_obj_shenlan_h_t *o, uint64_t *data) {
  452. assert(o);
  453. assert(data);
  454. register uint64_t x;
  455. register uint64_t m = 0;
  456. /* VcuPtTqLimMax: start-bit 7, length 16, endianess motorola, scaling 1, offset -32768 */
  457. x = ((uint16_t)(o->can_0x14a_ADC_14A.VcuPtTqLimMax)) & 0xffff;
  458. x <<= 48;
  459. m |= x;
  460. /* VcuPtTqLimMin: start-bit 23, length 16, endianess motorola, scaling 1, offset -32768 */
  461. x = ((uint16_t)(o->can_0x14a_ADC_14A.VcuPtTqLimMin)) & 0xffff;
  462. x <<= 32;
  463. m |= x;
  464. /* VcuPtTqReal: start-bit 39, length 16, endianess motorola, scaling 1, offset -32768 */
  465. x = ((uint16_t)(o->can_0x14a_ADC_14A.VcuPtTqReal)) & 0xffff;
  466. x <<= 16;
  467. m |= x;
  468. /* VcuShiftLvlPosn: start-bit 50, length 4, endianess motorola, scaling 1, offset 0 */
  469. x = ((uint8_t)(o->can_0x14a_ADC_14A.VcuShiftLvlPosn)) & 0xf;
  470. x <<= 7;
  471. m |= x;
  472. /* IBCU_ReduceFuncAvail: start-bit 52, length 2, endianess motorola, scaling 1, offset 0 */
  473. x = ((uint8_t)(o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail)) & 0x3;
  474. x <<= 11;
  475. m |= x;
  476. /* IBCU_FullFuncAvail: start-bit 54, length 2, endianess motorola, scaling 1, offset 0 */
  477. x = ((uint8_t)(o->can_0x14a_ADC_14A.IBCU_FullFuncAvail)) & 0x3;
  478. x <<= 13;
  479. m |= x;
  480. /* ESP_BrakeForce: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
  481. x = ((uint8_t)(o->can_0x14a_ADC_14A.ESP_BrakeForce)) & 0x1;
  482. x <<= 15;
  483. m |= x;
  484. *data = reverse_byte_order(m);
  485. o->can_0x14a_ADC_14A_tx = 1;
  486. return 0;
  487. }
  488. static int unpack_can_0x14a_ADC_14A(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  489. assert(o);
  490. assert(dlc <= 8);
  491. register uint64_t x;
  492. register uint64_t m = reverse_byte_order(data);
  493. if (dlc < 8)
  494. return -1;
  495. /* VcuPtTqLimMax: start-bit 7, length 16, endianess motorola, scaling 1, offset -32768 */
  496. x = (m >> 48) & 0xffff;
  497. o->can_0x14a_ADC_14A.VcuPtTqLimMax = x;
  498. /* VcuPtTqLimMin: start-bit 23, length 16, endianess motorola, scaling 1, offset -32768 */
  499. x = (m >> 32) & 0xffff;
  500. o->can_0x14a_ADC_14A.VcuPtTqLimMin = x;
  501. /* VcuPtTqReal: start-bit 39, length 16, endianess motorola, scaling 1, offset -32768 */
  502. x = (m >> 16) & 0xffff;
  503. o->can_0x14a_ADC_14A.VcuPtTqReal = x;
  504. /* VcuShiftLvlPosn: start-bit 50, length 4, endianess motorola, scaling 1, offset 0 */
  505. x = (m >> 7) & 0xf;
  506. o->can_0x14a_ADC_14A.VcuShiftLvlPosn = x;
  507. /* IBCU_ReduceFuncAvail: start-bit 52, length 2, endianess motorola, scaling 1, offset 0 */
  508. x = (m >> 11) & 0x3;
  509. o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail = x;
  510. /* IBCU_FullFuncAvail: start-bit 54, length 2, endianess motorola, scaling 1, offset 0 */
  511. x = (m >> 13) & 0x3;
  512. o->can_0x14a_ADC_14A.IBCU_FullFuncAvail = x;
  513. /* ESP_BrakeForce: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
  514. x = (m >> 15) & 0x1;
  515. o->can_0x14a_ADC_14A.ESP_BrakeForce = x;
  516. o->can_0x14a_ADC_14A_rx = 1;
  517. o->can_0x14a_ADC_14A_time_stamp_rx = time_stamp;
  518. return 0;
  519. }
  520. int decode_can_0x14a_VcuPtTqLimMax(const can_obj_shenlan_h_t *o, double *out) {
  521. assert(o);
  522. assert(out);
  523. double rval = (double)(o->can_0x14a_ADC_14A.VcuPtTqLimMax);
  524. rval += -32768;
  525. if (rval <= 32767) {
  526. *out = rval;
  527. return 0;
  528. } else {
  529. *out = (double)0;
  530. return -1;
  531. }
  532. }
  533. int encode_can_0x14a_VcuPtTqLimMax(can_obj_shenlan_h_t *o, double in) {
  534. assert(o);
  535. o->can_0x14a_ADC_14A.VcuPtTqLimMax = 0;
  536. if (in > 32767)
  537. return -1;
  538. in += 32768;
  539. o->can_0x14a_ADC_14A.VcuPtTqLimMax = in;
  540. return 0;
  541. }
  542. int decode_can_0x14a_VcuPtTqLimMin(const can_obj_shenlan_h_t *o, double *out) {
  543. assert(o);
  544. assert(out);
  545. double rval = (double)(o->can_0x14a_ADC_14A.VcuPtTqLimMin);
  546. rval += -32768;
  547. if (rval <= 32767) {
  548. *out = rval;
  549. return 0;
  550. } else {
  551. *out = (double)0;
  552. return -1;
  553. }
  554. }
  555. int encode_can_0x14a_VcuPtTqLimMin(can_obj_shenlan_h_t *o, double in) {
  556. assert(o);
  557. o->can_0x14a_ADC_14A.VcuPtTqLimMin = 0;
  558. if (in > 32767)
  559. return -1;
  560. in += 32768;
  561. o->can_0x14a_ADC_14A.VcuPtTqLimMin = in;
  562. return 0;
  563. }
  564. int decode_can_0x14a_VcuPtTqReal(const can_obj_shenlan_h_t *o, double *out) {
  565. assert(o);
  566. assert(out);
  567. double rval = (double)(o->can_0x14a_ADC_14A.VcuPtTqReal);
  568. rval += -32768;
  569. if (rval <= 32767) {
  570. *out = rval;
  571. return 0;
  572. } else {
  573. *out = (double)0;
  574. return -1;
  575. }
  576. }
  577. int encode_can_0x14a_VcuPtTqReal(can_obj_shenlan_h_t *o, double in) {
  578. assert(o);
  579. o->can_0x14a_ADC_14A.VcuPtTqReal = 0;
  580. if (in > 32767)
  581. return -1;
  582. in += 32768;
  583. o->can_0x14a_ADC_14A.VcuPtTqReal = in;
  584. return 0;
  585. }
  586. int decode_can_0x14a_VcuShiftLvlPosn(const can_obj_shenlan_h_t *o, uint8_t *out) {
  587. assert(o);
  588. assert(out);
  589. uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.VcuShiftLvlPosn);
  590. *out = rval;
  591. return 0;
  592. }
  593. int encode_can_0x14a_VcuShiftLvlPosn(can_obj_shenlan_h_t *o, uint8_t in) {
  594. assert(o);
  595. o->can_0x14a_ADC_14A.VcuShiftLvlPosn = in;
  596. return 0;
  597. }
  598. int decode_can_0x14a_IBCU_ReduceFuncAvail(const can_obj_shenlan_h_t *o, uint8_t *out) {
  599. assert(o);
  600. assert(out);
  601. uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail);
  602. *out = rval;
  603. return 0;
  604. }
  605. int encode_can_0x14a_IBCU_ReduceFuncAvail(can_obj_shenlan_h_t *o, uint8_t in) {
  606. assert(o);
  607. o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail = in;
  608. return 0;
  609. }
  610. int decode_can_0x14a_IBCU_FullFuncAvail(const can_obj_shenlan_h_t *o, uint8_t *out) {
  611. assert(o);
  612. assert(out);
  613. uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.IBCU_FullFuncAvail);
  614. *out = rval;
  615. return 0;
  616. }
  617. int encode_can_0x14a_IBCU_FullFuncAvail(can_obj_shenlan_h_t *o, uint8_t in) {
  618. assert(o);
  619. o->can_0x14a_ADC_14A.IBCU_FullFuncAvail = in;
  620. return 0;
  621. }
  622. int decode_can_0x14a_ESP_BrakeForce(const can_obj_shenlan_h_t *o, uint8_t *out) {
  623. assert(o);
  624. assert(out);
  625. uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.ESP_BrakeForce);
  626. *out = rval;
  627. return 0;
  628. }
  629. int encode_can_0x14a_ESP_BrakeForce(can_obj_shenlan_h_t *o, uint8_t in) {
  630. assert(o);
  631. o->can_0x14a_ADC_14A.ESP_BrakeForce = in;
  632. return 0;
  633. }
  634. int print_can_0x14a_ADC_14A(const can_obj_shenlan_h_t *o) {
  635. assert(o);
  636. int r = 0;
  637. double VcuPtTqLimMax = 0.0;
  638. decode_can_0x14a_VcuPtTqLimMax(o,&VcuPtTqLimMax);
  639. printf("\tVcuPtTqLimMax = %f\r\n", VcuPtTqLimMax);
  640. double VcuPtTqLimMin = 0.0;
  641. decode_can_0x14a_VcuPtTqLimMin(o,&VcuPtTqLimMin);
  642. printf("\tVcuPtTqLimMin = %f\r\n", VcuPtTqLimMin);
  643. double VcuPtTqReal = 0.0;
  644. decode_can_0x14a_VcuPtTqReal(o,&VcuPtTqReal);
  645. printf("\tVcuPtTqReal = %f\r\n", VcuPtTqReal);
  646. printf("\tVcuShiftLvlPosn = %d\r\n", (o->can_0x14a_ADC_14A.VcuShiftLvlPosn));
  647. printf("\tIBCU_ReduceFuncAvail = %d\r\n", (o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail));
  648. printf("\tIBCU_FullFuncAvail = %d\r\n", (o->can_0x14a_ADC_14A.IBCU_FullFuncAvail));
  649. printf("\tESP_BrakeForce = %d\r\n", (o->can_0x14a_ADC_14A.ESP_BrakeForce));
  650. return r;
  651. }
  652. static int pack_can_0x24b_ECU_24B(can_obj_shenlan_h_t *o, uint64_t *data) {
  653. assert(o);
  654. assert(data);
  655. register uint64_t x;
  656. register uint64_t m = 0;
  657. /* ACC_AEBTargetDeceleration: start-bit 24, length 16, endianess motorola, scaling 0.0005, offset -16 */
  658. x = ((uint16_t)(o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration)) & 0xffff;
  659. x <<= 17;
  660. m |= x;
  661. /* ACC_AccTrqReq: start-bit 7, length 15, endianess motorola, scaling 1, offset -16384 */
  662. x = ((uint16_t)(o->can_0x24b_ECU_24B.ACC_AccTrqReq)) & 0x7fff;
  663. x <<= 49;
  664. m |= x;
  665. /* ACC_ACCTargetAcceleration: start-bit 20, length 8, endianess motorola, scaling 0.05, offset -10 */
  666. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration)) & 0xff;
  667. x <<= 37;
  668. m |= x;
  669. /* ACC_ACCMode: start-bit 58, length 3, endianess motorola, scaling 1, offset 0 */
  670. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_ACCMode)) & 0x7;
  671. m |= x;
  672. /* ADCReqMode: start-bit 50, length 2, endianess motorola, scaling 1, offset 0 */
  673. x = ((uint8_t)(o->can_0x24b_ECU_24B.ADCReqMode)) & 0x3;
  674. x <<= 9;
  675. m |= x;
  676. /* ACC_AccTrqReqActive: start-bit 8, length 1, endianess motorola, scaling 1, offset 0 */
  677. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_AccTrqReqActive)) & 0x1;
  678. x <<= 48;
  679. m |= x;
  680. /* ACC_AEBVehilceHoldReq: start-bit 40, length 1, endianess motorola, scaling 1, offset 0 */
  681. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq)) & 0x1;
  682. x <<= 16;
  683. m |= x;
  684. /* ACC_AEBActive: start-bit 51, length 1, endianess motorola, scaling 1, offset 0 */
  685. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBActive)) & 0x1;
  686. x <<= 11;
  687. m |= x;
  688. /* ACC_Driveoff_Request: start-bit 53, length 1, endianess motorola, scaling 1, offset 0 */
  689. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_Driveoff_Request)) & 0x1;
  690. x <<= 13;
  691. m |= x;
  692. /* ACC_DecToStop: start-bit 54, length 1, endianess motorola, scaling 1, offset 0 */
  693. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_DecToStop)) & 0x1;
  694. x <<= 14;
  695. m |= x;
  696. /* ACC_CDDActive: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
  697. x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_CDDActive)) & 0x1;
  698. x <<= 15;
  699. m |= x;
  700. *data = reverse_byte_order(m);
  701. o->can_0x24b_ECU_24B_tx = 1;
  702. return 0;
  703. }
  704. static int unpack_can_0x24b_ECU_24B(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  705. assert(o);
  706. assert(dlc <= 8);
  707. register uint64_t x;
  708. register uint64_t m = reverse_byte_order(data);
  709. if (dlc < 8)
  710. return -1;
  711. /* ACC_AEBTargetDeceleration: start-bit 24, length 16, endianess motorola, scaling 0.0005, offset -16 */
  712. x = (m >> 17) & 0xffff;
  713. o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration = x;
  714. /* ACC_AccTrqReq: start-bit 7, length 15, endianess motorola, scaling 1, offset -16384 */
  715. x = (m >> 49) & 0x7fff;
  716. o->can_0x24b_ECU_24B.ACC_AccTrqReq = x;
  717. /* ACC_ACCTargetAcceleration: start-bit 20, length 8, endianess motorola, scaling 0.05, offset -10 */
  718. x = (m >> 37) & 0xff;
  719. o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration = x;
  720. /* ACC_ACCMode: start-bit 58, length 3, endianess motorola, scaling 1, offset 0 */
  721. x = m & 0x7;
  722. o->can_0x24b_ECU_24B.ACC_ACCMode = x;
  723. /* ADCReqMode: start-bit 50, length 2, endianess motorola, scaling 1, offset 0 */
  724. x = (m >> 9) & 0x3;
  725. o->can_0x24b_ECU_24B.ADCReqMode = x;
  726. /* ACC_AccTrqReqActive: start-bit 8, length 1, endianess motorola, scaling 1, offset 0 */
  727. x = (m >> 48) & 0x1;
  728. o->can_0x24b_ECU_24B.ACC_AccTrqReqActive = x;
  729. /* ACC_AEBVehilceHoldReq: start-bit 40, length 1, endianess motorola, scaling 1, offset 0 */
  730. x = (m >> 16) & 0x1;
  731. o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq = x;
  732. /* ACC_AEBActive: start-bit 51, length 1, endianess motorola, scaling 1, offset 0 */
  733. x = (m >> 11) & 0x1;
  734. o->can_0x24b_ECU_24B.ACC_AEBActive = x;
  735. /* ACC_Driveoff_Request: start-bit 53, length 1, endianess motorola, scaling 1, offset 0 */
  736. x = (m >> 13) & 0x1;
  737. o->can_0x24b_ECU_24B.ACC_Driveoff_Request = x;
  738. /* ACC_DecToStop: start-bit 54, length 1, endianess motorola, scaling 1, offset 0 */
  739. x = (m >> 14) & 0x1;
  740. o->can_0x24b_ECU_24B.ACC_DecToStop = x;
  741. /* ACC_CDDActive: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
  742. x = (m >> 15) & 0x1;
  743. o->can_0x24b_ECU_24B.ACC_CDDActive = x;
  744. o->can_0x24b_ECU_24B_rx = 1;
  745. o->can_0x24b_ECU_24B_time_stamp_rx = time_stamp;
  746. return 0;
  747. }
  748. int decode_can_0x24b_ACC_AEBTargetDeceleration(const can_obj_shenlan_h_t *o, double *out) {
  749. assert(o);
  750. assert(out);
  751. double rval = (double)(o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration);
  752. rval *= 0.0005;
  753. rval += -16;
  754. if (rval <= 16) {
  755. *out = rval;
  756. return 0;
  757. } else {
  758. *out = (double)0;
  759. return -1;
  760. }
  761. }
  762. int encode_can_0x24b_ACC_AEBTargetDeceleration(can_obj_shenlan_h_t *o, double in) {
  763. assert(o);
  764. o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration = 0;
  765. if (in > 16)
  766. return -1;
  767. in += 16;
  768. in *= 2000;
  769. o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration = in;
  770. return 0;
  771. }
  772. int decode_can_0x24b_ACC_AccTrqReq(const can_obj_shenlan_h_t *o, double *out) {
  773. assert(o);
  774. assert(out);
  775. double rval = (double)(o->can_0x24b_ECU_24B.ACC_AccTrqReq);
  776. rval += -16384;
  777. if (rval <= 16383) {
  778. *out = rval;
  779. return 0;
  780. } else {
  781. *out = (double)0;
  782. return -1;
  783. }
  784. }
  785. int encode_can_0x24b_ACC_AccTrqReq(can_obj_shenlan_h_t *o, double in) {
  786. assert(o);
  787. o->can_0x24b_ECU_24B.ACC_AccTrqReq = 0;
  788. if (in > 16383)
  789. return -1;
  790. in += 16384;
  791. o->can_0x24b_ECU_24B.ACC_AccTrqReq = in;
  792. return 0;
  793. }
  794. int decode_can_0x24b_ACC_ACCTargetAcceleration(const can_obj_shenlan_h_t *o, double *out) {
  795. assert(o);
  796. assert(out);
  797. double rval = (double)(o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration);
  798. rval *= 0.05;
  799. rval += -10;
  800. if (rval <= 2.75) {
  801. *out = rval;
  802. return 0;
  803. } else {
  804. *out = (double)0;
  805. return -1;
  806. }
  807. }
  808. int encode_can_0x24b_ACC_ACCTargetAcceleration(can_obj_shenlan_h_t *o, double in) {
  809. assert(o);
  810. o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration = 0;
  811. if (in > 2.75)
  812. return -1;
  813. in += 10;
  814. in *= 20;
  815. o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration = in;
  816. return 0;
  817. }
  818. int decode_can_0x24b_ACC_ACCMode(const can_obj_shenlan_h_t *o, uint8_t *out) {
  819. assert(o);
  820. assert(out);
  821. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_ACCMode);
  822. *out = rval;
  823. return 0;
  824. }
  825. int encode_can_0x24b_ACC_ACCMode(can_obj_shenlan_h_t *o, uint8_t in) {
  826. assert(o);
  827. o->can_0x24b_ECU_24B.ACC_ACCMode = in;
  828. return 0;
  829. }
  830. int decode_can_0x24b_ADCReqMode(const can_obj_shenlan_h_t *o, uint8_t *out) {
  831. assert(o);
  832. assert(out);
  833. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ADCReqMode);
  834. *out = rval;
  835. return 0;
  836. }
  837. int encode_can_0x24b_ADCReqMode(can_obj_shenlan_h_t *o, uint8_t in) {
  838. assert(o);
  839. o->can_0x24b_ECU_24B.ADCReqMode = in;
  840. return 0;
  841. }
  842. int decode_can_0x24b_ACC_AccTrqReqActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
  843. assert(o);
  844. assert(out);
  845. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_AccTrqReqActive);
  846. *out = rval;
  847. return 0;
  848. }
  849. int encode_can_0x24b_ACC_AccTrqReqActive(can_obj_shenlan_h_t *o, uint8_t in) {
  850. assert(o);
  851. o->can_0x24b_ECU_24B.ACC_AccTrqReqActive = in;
  852. return 0;
  853. }
  854. int decode_can_0x24b_ACC_AEBVehilceHoldReq(const can_obj_shenlan_h_t *o, uint8_t *out) {
  855. assert(o);
  856. assert(out);
  857. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq);
  858. *out = rval;
  859. return 0;
  860. }
  861. int encode_can_0x24b_ACC_AEBVehilceHoldReq(can_obj_shenlan_h_t *o, uint8_t in) {
  862. assert(o);
  863. o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq = in;
  864. return 0;
  865. }
  866. int decode_can_0x24b_ACC_AEBActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
  867. assert(o);
  868. assert(out);
  869. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBActive);
  870. *out = rval;
  871. return 0;
  872. }
  873. int encode_can_0x24b_ACC_AEBActive(can_obj_shenlan_h_t *o, uint8_t in) {
  874. assert(o);
  875. o->can_0x24b_ECU_24B.ACC_AEBActive = in;
  876. return 0;
  877. }
  878. int decode_can_0x24b_ACC_Driveoff_Request(const can_obj_shenlan_h_t *o, uint8_t *out) {
  879. assert(o);
  880. assert(out);
  881. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_Driveoff_Request);
  882. *out = rval;
  883. return 0;
  884. }
  885. int encode_can_0x24b_ACC_Driveoff_Request(can_obj_shenlan_h_t *o, uint8_t in) {
  886. assert(o);
  887. o->can_0x24b_ECU_24B.ACC_Driveoff_Request = in;
  888. return 0;
  889. }
  890. int decode_can_0x24b_ACC_DecToStop(const can_obj_shenlan_h_t *o, uint8_t *out) {
  891. assert(o);
  892. assert(out);
  893. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_DecToStop);
  894. *out = rval;
  895. return 0;
  896. }
  897. int encode_can_0x24b_ACC_DecToStop(can_obj_shenlan_h_t *o, uint8_t in) {
  898. assert(o);
  899. o->can_0x24b_ECU_24B.ACC_DecToStop = in;
  900. return 0;
  901. }
  902. int decode_can_0x24b_ACC_CDDActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
  903. assert(o);
  904. assert(out);
  905. uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_CDDActive);
  906. *out = rval;
  907. return 0;
  908. }
  909. int encode_can_0x24b_ACC_CDDActive(can_obj_shenlan_h_t *o, uint8_t in) {
  910. assert(o);
  911. o->can_0x24b_ECU_24B.ACC_CDDActive = in;
  912. return 0;
  913. }
  914. int print_can_0x24b_ECU_24B(const can_obj_shenlan_h_t *o) {
  915. assert(o);
  916. int r = 0;
  917. double ACC_AEBTargetDeceleration = 0.0;
  918. decode_can_0x24b_ACC_AEBTargetDeceleration(o,&ACC_AEBTargetDeceleration);
  919. printf("\tACC_AEBTargetDeceleration = %f\r\n", ACC_AEBTargetDeceleration);
  920. double ACC_AccTrqReq = 0.0;
  921. decode_can_0x24b_ACC_AccTrqReq(o,&ACC_AccTrqReq);
  922. printf("\tACC_AccTrqReq = %f\r\n", ACC_AccTrqReq);
  923. double ACC_ACCTargetAcceleration = 0.0;
  924. decode_can_0x24b_ACC_ACCTargetAcceleration(o,&ACC_ACCTargetAcceleration);
  925. printf("\tACC_ACCTargetAcceleration = %f\r\n", ACC_ACCTargetAcceleration);
  926. printf("\tACC_ACCMode = %d\r\n", (o->can_0x24b_ECU_24B.ACC_ACCMode));
  927. printf("\tADCReqMode = %d\r\n", (o->can_0x24b_ECU_24B.ADCReqMode));
  928. printf("\tACC_AccTrqReqActive = %d\r\n", (o->can_0x24b_ECU_24B.ACC_AccTrqReqActive));
  929. printf("\tACC_AEBVehilceHoldReq = %d\r\n", (o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq));
  930. printf("\tACC_AEBActive = %d\r\n", (o->can_0x24b_ECU_24B.ACC_AEBActive));
  931. printf("\tACC_Driveoff_Request = %d\r\n", (o->can_0x24b_ECU_24B.ACC_Driveoff_Request));
  932. printf("\tACC_DecToStop = %d\r\n", (o->can_0x24b_ECU_24B.ACC_DecToStop));
  933. printf("\tACC_CDDActive = %d\r\n", (o->can_0x24b_ECU_24B.ACC_CDDActive));
  934. return r;
  935. }
  936. static int pack_can_0x250_ADC_250(can_obj_shenlan_h_t *o, uint64_t *data) {
  937. assert(o);
  938. assert(data);
  939. register uint64_t x;
  940. register uint64_t m = 0;
  941. /* ESP_YawRate: start-bit 2, length 14, endianess motorola, scaling 0.01, offset -81.91 */
  942. x = ((uint16_t)(o->can_0x250_ADC_250.ESP_YawRate)) & 0x3fff;
  943. x <<= 45;
  944. m |= x;
  945. /* ESP_LongAccel: start-bit 20, length 10, endianess motorola, scaling 0.03125, offset -16 */
  946. x = ((uint16_t)(o->can_0x250_ADC_250.ESP_LongAccel)) & 0x3ff;
  947. x <<= 35;
  948. m |= x;
  949. /* ESP_LatAccel: start-bit 24, length 8, endianess motorola, scaling 0.1, offset -12.7 */
  950. x = ((uint8_t)(o->can_0x250_ADC_250.ESP_LatAccel)) & 0xff;
  951. x <<= 25;
  952. m |= x;
  953. /* EPS_ADS_ControlFeedback: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
  954. x = ((uint8_t)(o->can_0x250_ADC_250.EPS_ADS_ControlFeedback)) & 0x7;
  955. x <<= 61;
  956. m |= x;
  957. /* ESP_YawRateValid: start-bit 4, length 2, endianess motorola, scaling 1, offset 0 */
  958. x = ((uint8_t)(o->can_0x250_ADC_250.ESP_YawRateValid)) & 0x3;
  959. x <<= 59;
  960. m |= x;
  961. /* ESP_LongAccelValid: start-bit 26, length 2, endianess motorola, scaling 1, offset 0 */
  962. x = ((uint8_t)(o->can_0x250_ADC_250.ESP_LongAccelValid)) & 0x3;
  963. x <<= 33;
  964. m |= x;
  965. /* ESP_LatAccelValid: start-bit 32, length 2, endianess motorola, scaling 1, offset 0 */
  966. x = ((uint8_t)(o->can_0x250_ADC_250.ESP_LatAccelValid)) & 0x3;
  967. x <<= 23;
  968. m |= x;
  969. *data = reverse_byte_order(m);
  970. o->can_0x250_ADC_250_tx = 1;
  971. return 0;
  972. }
  973. static int unpack_can_0x250_ADC_250(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  974. assert(o);
  975. assert(dlc <= 8);
  976. register uint64_t x;
  977. register uint64_t m = reverse_byte_order(data);
  978. if (dlc < 8)
  979. return -1;
  980. /* ESP_YawRate: start-bit 2, length 14, endianess motorola, scaling 0.01, offset -81.91 */
  981. x = (m >> 45) & 0x3fff;
  982. o->can_0x250_ADC_250.ESP_YawRate = x;
  983. /* ESP_LongAccel: start-bit 20, length 10, endianess motorola, scaling 0.03125, offset -16 */
  984. x = (m >> 35) & 0x3ff;
  985. o->can_0x250_ADC_250.ESP_LongAccel = x;
  986. /* ESP_LatAccel: start-bit 24, length 8, endianess motorola, scaling 0.1, offset -12.7 */
  987. x = (m >> 25) & 0xff;
  988. o->can_0x250_ADC_250.ESP_LatAccel = x;
  989. /* EPS_ADS_ControlFeedback: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
  990. x = (m >> 61) & 0x7;
  991. o->can_0x250_ADC_250.EPS_ADS_ControlFeedback = x;
  992. /* ESP_YawRateValid: start-bit 4, length 2, endianess motorola, scaling 1, offset 0 */
  993. x = (m >> 59) & 0x3;
  994. o->can_0x250_ADC_250.ESP_YawRateValid = x;
  995. /* ESP_LongAccelValid: start-bit 26, length 2, endianess motorola, scaling 1, offset 0 */
  996. x = (m >> 33) & 0x3;
  997. o->can_0x250_ADC_250.ESP_LongAccelValid = x;
  998. /* ESP_LatAccelValid: start-bit 32, length 2, endianess motorola, scaling 1, offset 0 */
  999. x = (m >> 23) & 0x3;
  1000. o->can_0x250_ADC_250.ESP_LatAccelValid = x;
  1001. o->can_0x250_ADC_250_rx = 1;
  1002. o->can_0x250_ADC_250_time_stamp_rx = time_stamp;
  1003. return 0;
  1004. }
  1005. int decode_can_0x250_ESP_YawRate(const can_obj_shenlan_h_t *o, double *out) {
  1006. assert(o);
  1007. assert(out);
  1008. double rval = (double)(o->can_0x250_ADC_250.ESP_YawRate);
  1009. rval *= 0.01;
  1010. rval += -81.91;
  1011. if (rval <= 81.92) {
  1012. *out = rval;
  1013. return 0;
  1014. } else {
  1015. *out = (double)0;
  1016. return -1;
  1017. }
  1018. }
  1019. int encode_can_0x250_ESP_YawRate(can_obj_shenlan_h_t *o, double in) {
  1020. assert(o);
  1021. o->can_0x250_ADC_250.ESP_YawRate = 0;
  1022. if (in > 81.92)
  1023. return -1;
  1024. in += 81.91;
  1025. in *= 100;
  1026. o->can_0x250_ADC_250.ESP_YawRate = in;
  1027. return 0;
  1028. }
  1029. int decode_can_0x250_ESP_LongAccel(const can_obj_shenlan_h_t *o, double *out) {
  1030. assert(o);
  1031. assert(out);
  1032. double rval = (double)(o->can_0x250_ADC_250.ESP_LongAccel);
  1033. rval *= 0.03125;
  1034. rval += -16;
  1035. if (rval <= 15.9062) {
  1036. *out = rval;
  1037. return 0;
  1038. } else {
  1039. *out = (double)0;
  1040. return -1;
  1041. }
  1042. }
  1043. int encode_can_0x250_ESP_LongAccel(can_obj_shenlan_h_t *o, double in) {
  1044. assert(o);
  1045. o->can_0x250_ADC_250.ESP_LongAccel = 0;
  1046. if (in > 15.9062)
  1047. return -1;
  1048. in += 16;
  1049. in *= 32;
  1050. o->can_0x250_ADC_250.ESP_LongAccel = in;
  1051. return 0;
  1052. }
  1053. int decode_can_0x250_ESP_LatAccel(const can_obj_shenlan_h_t *o, double *out) {
  1054. assert(o);
  1055. assert(out);
  1056. double rval = (double)(o->can_0x250_ADC_250.ESP_LatAccel);
  1057. rval *= 0.1;
  1058. rval += -12.7;
  1059. if (rval <= 12.7) {
  1060. *out = rval;
  1061. return 0;
  1062. } else {
  1063. *out = (double)0;
  1064. return -1;
  1065. }
  1066. }
  1067. int encode_can_0x250_ESP_LatAccel(can_obj_shenlan_h_t *o, double in) {
  1068. assert(o);
  1069. o->can_0x250_ADC_250.ESP_LatAccel = 0;
  1070. if (in > 12.7)
  1071. return -1;
  1072. in += 12.7;
  1073. in *= 10;
  1074. o->can_0x250_ADC_250.ESP_LatAccel = in;
  1075. return 0;
  1076. }
  1077. int decode_can_0x250_EPS_ADS_ControlFeedback(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1078. assert(o);
  1079. assert(out);
  1080. uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.EPS_ADS_ControlFeedback);
  1081. *out = rval;
  1082. return 0;
  1083. }
  1084. int encode_can_0x250_EPS_ADS_ControlFeedback(can_obj_shenlan_h_t *o, uint8_t in) {
  1085. assert(o);
  1086. o->can_0x250_ADC_250.EPS_ADS_ControlFeedback = in;
  1087. return 0;
  1088. }
  1089. int decode_can_0x250_ESP_YawRateValid(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1090. assert(o);
  1091. assert(out);
  1092. uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.ESP_YawRateValid);
  1093. *out = rval;
  1094. return 0;
  1095. }
  1096. int encode_can_0x250_ESP_YawRateValid(can_obj_shenlan_h_t *o, uint8_t in) {
  1097. assert(o);
  1098. o->can_0x250_ADC_250.ESP_YawRateValid = in;
  1099. return 0;
  1100. }
  1101. int decode_can_0x250_ESP_LongAccelValid(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1102. assert(o);
  1103. assert(out);
  1104. uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.ESP_LongAccelValid);
  1105. *out = rval;
  1106. return 0;
  1107. }
  1108. int encode_can_0x250_ESP_LongAccelValid(can_obj_shenlan_h_t *o, uint8_t in) {
  1109. assert(o);
  1110. o->can_0x250_ADC_250.ESP_LongAccelValid = in;
  1111. return 0;
  1112. }
  1113. int decode_can_0x250_ESP_LatAccelValid(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1114. assert(o);
  1115. assert(out);
  1116. uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.ESP_LatAccelValid);
  1117. *out = rval;
  1118. return 0;
  1119. }
  1120. int encode_can_0x250_ESP_LatAccelValid(can_obj_shenlan_h_t *o, uint8_t in) {
  1121. assert(o);
  1122. o->can_0x250_ADC_250.ESP_LatAccelValid = in;
  1123. return 0;
  1124. }
  1125. int print_can_0x250_ADC_250(const can_obj_shenlan_h_t *o) {
  1126. assert(o);
  1127. int r = 0;
  1128. double ESP_YawRate = 0.0;
  1129. decode_can_0x250_ESP_YawRate(o,&ESP_YawRate);
  1130. printf("\tESP_YawRate = %f\r\n", ESP_YawRate);
  1131. double ESP_LongAccel = 0.0;
  1132. decode_can_0x250_ESP_LongAccel(o,&ESP_LongAccel);
  1133. printf("\tESP_LongAccel = %f\r\n", ESP_LongAccel);
  1134. double ESP_LatAccel = 0.0;
  1135. decode_can_0x250_ESP_LatAccel(o,&ESP_LatAccel);
  1136. printf("\tESP_LatAccel = %f\r\n", ESP_LatAccel);
  1137. printf("\tEPS_ADS_ControlFeedback = %d\r\n", (o->can_0x250_ADC_250.EPS_ADS_ControlFeedback));
  1138. printf("\tESP_YawRateValid = %d\r\n", (o->can_0x250_ADC_250.ESP_YawRateValid));
  1139. printf("\tESP_LongAccelValid = %d\r\n", (o->can_0x250_ADC_250.ESP_LongAccelValid));
  1140. printf("\tESP_LatAccelValid = %d\r\n", (o->can_0x250_ADC_250.ESP_LatAccelValid));
  1141. return r;
  1142. }
  1143. static int pack_can_0x358_ADC_358(can_obj_shenlan_h_t *o, uint64_t *data) {
  1144. assert(o);
  1145. assert(data);
  1146. register uint64_t x;
  1147. register uint64_t m = 0;
  1148. /* ADS_UDLCTurnLightReq: start-bit 26, length 3, endianess motorola, scaling 1, offset 0 */
  1149. x = ((uint8_t)(o->can_0x358_ADC_358.ADS_UDLCTurnLightReq)) & 0x7;
  1150. x <<= 32;
  1151. m |= x;
  1152. *data = reverse_byte_order(m);
  1153. o->can_0x358_ADC_358_tx = 1;
  1154. return 0;
  1155. }
  1156. static int unpack_can_0x358_ADC_358(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  1157. assert(o);
  1158. assert(dlc <= 8);
  1159. register uint64_t x;
  1160. register uint64_t m = reverse_byte_order(data);
  1161. if (dlc < 8)
  1162. return -1;
  1163. /* ADS_UDLCTurnLightReq: start-bit 26, length 3, endianess motorola, scaling 1, offset 0 */
  1164. x = (m >> 32) & 0x7;
  1165. o->can_0x358_ADC_358.ADS_UDLCTurnLightReq = x;
  1166. o->can_0x358_ADC_358_rx = 1;
  1167. o->can_0x358_ADC_358_time_stamp_rx = time_stamp;
  1168. return 0;
  1169. }
  1170. int decode_can_0x358_ADS_UDLCTurnLightReq(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1171. assert(o);
  1172. assert(out);
  1173. uint8_t rval = (uint8_t)(o->can_0x358_ADC_358.ADS_UDLCTurnLightReq);
  1174. *out = rval;
  1175. return 0;
  1176. }
  1177. int encode_can_0x358_ADS_UDLCTurnLightReq(can_obj_shenlan_h_t *o, uint8_t in) {
  1178. assert(o);
  1179. o->can_0x358_ADC_358.ADS_UDLCTurnLightReq = in;
  1180. return 0;
  1181. }
  1182. int print_can_0x358_ADC_358(const can_obj_shenlan_h_t *o) {
  1183. assert(o);
  1184. int r = 0;
  1185. printf("\tADS_UDLCTurnLightReq = %d\r\n", (o->can_0x358_ADC_358.ADS_UDLCTurnLightReq));
  1186. return r;
  1187. }
  1188. static int pack_can_0x36e_ECU_36E(can_obj_shenlan_h_t *o, uint64_t *data) {
  1189. assert(o);
  1190. assert(data);
  1191. register uint64_t x;
  1192. register uint64_t m = 0;
  1193. /* ADS_UDLCTurnLightReq: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
  1194. x = ((uint8_t)(o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq)) & 0x7;
  1195. x <<= 61;
  1196. m |= x;
  1197. *data = reverse_byte_order(m);
  1198. o->can_0x36e_ECU_36E_tx = 1;
  1199. return 0;
  1200. }
  1201. static int unpack_can_0x36e_ECU_36E(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  1202. assert(o);
  1203. assert(dlc <= 8);
  1204. register uint64_t x;
  1205. register uint64_t m = reverse_byte_order(data);
  1206. if (dlc < 8)
  1207. return -1;
  1208. /* ADS_UDLCTurnLightReq: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
  1209. x = (m >> 61) & 0x7;
  1210. o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq = x;
  1211. o->can_0x36e_ECU_36E_rx = 1;
  1212. o->can_0x36e_ECU_36E_time_stamp_rx = time_stamp;
  1213. return 0;
  1214. }
  1215. int decode_can_0x36e_ADS_UDLCTurnLightReq(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1216. assert(o);
  1217. assert(out);
  1218. uint8_t rval = (uint8_t)(o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq);
  1219. *out = rval;
  1220. return 0;
  1221. }
  1222. int encode_can_0x36e_ADS_UDLCTurnLightReq(can_obj_shenlan_h_t *o, uint8_t in) {
  1223. assert(o);
  1224. o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq = in;
  1225. return 0;
  1226. }
  1227. int print_can_0x36e_ECU_36E(const can_obj_shenlan_h_t *o) {
  1228. assert(o);
  1229. int r = 0;
  1230. printf("\tADS_UDLCTurnLightReq = %d\r\n", (o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq));
  1231. return r;
  1232. }
  1233. static int pack_can_0x3aa_ADC_3AA(can_obj_shenlan_h_t *o, uint64_t *data) {
  1234. assert(o);
  1235. assert(data);
  1236. register uint64_t x;
  1237. register uint64_t m = 0;
  1238. /* VcuCrsSetSwtSts: start-bit 3, length 2, endianess motorola, scaling 1, offset 0 */
  1239. x = ((uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts)) & 0x3;
  1240. x <<= 58;
  1241. m |= x;
  1242. /* VcuCrsResuSwtSts: start-bit 5, length 2, endianess motorola, scaling 1, offset 0 */
  1243. x = ((uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts)) & 0x3;
  1244. x <<= 60;
  1245. m |= x;
  1246. /* VcuCrsDstSwtPlusSts: start-bit 7, length 2, endianess motorola, scaling 1, offset 0 */
  1247. x = ((uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts)) & 0x3;
  1248. x <<= 62;
  1249. m |= x;
  1250. *data = reverse_byte_order(m);
  1251. o->can_0x3aa_ADC_3AA_tx = 1;
  1252. return 0;
  1253. }
  1254. static int unpack_can_0x3aa_ADC_3AA(can_obj_shenlan_h_t *o, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  1255. assert(o);
  1256. assert(dlc <= 8);
  1257. register uint64_t x;
  1258. register uint64_t m = reverse_byte_order(data);
  1259. if (dlc < 8)
  1260. return -1;
  1261. /* VcuCrsSetSwtSts: start-bit 3, length 2, endianess motorola, scaling 1, offset 0 */
  1262. x = (m >> 58) & 0x3;
  1263. o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts = x;
  1264. /* VcuCrsResuSwtSts: start-bit 5, length 2, endianess motorola, scaling 1, offset 0 */
  1265. x = (m >> 60) & 0x3;
  1266. o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts = x;
  1267. /* VcuCrsDstSwtPlusSts: start-bit 7, length 2, endianess motorola, scaling 1, offset 0 */
  1268. x = (m >> 62) & 0x3;
  1269. o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts = x;
  1270. o->can_0x3aa_ADC_3AA_rx = 1;
  1271. o->can_0x3aa_ADC_3AA_time_stamp_rx = time_stamp;
  1272. return 0;
  1273. }
  1274. int decode_can_0x3aa_VcuCrsSetSwtSts(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1275. assert(o);
  1276. assert(out);
  1277. uint8_t rval = (uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts);
  1278. *out = rval;
  1279. return 0;
  1280. }
  1281. int encode_can_0x3aa_VcuCrsSetSwtSts(can_obj_shenlan_h_t *o, uint8_t in) {
  1282. assert(o);
  1283. o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts = in;
  1284. return 0;
  1285. }
  1286. int decode_can_0x3aa_VcuCrsResuSwtSts(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1287. assert(o);
  1288. assert(out);
  1289. uint8_t rval = (uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts);
  1290. *out = rval;
  1291. return 0;
  1292. }
  1293. int encode_can_0x3aa_VcuCrsResuSwtSts(can_obj_shenlan_h_t *o, uint8_t in) {
  1294. assert(o);
  1295. o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts = in;
  1296. return 0;
  1297. }
  1298. int decode_can_0x3aa_VcuCrsDstSwtPlusSts(const can_obj_shenlan_h_t *o, uint8_t *out) {
  1299. assert(o);
  1300. assert(out);
  1301. uint8_t rval = (uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts);
  1302. *out = rval;
  1303. return 0;
  1304. }
  1305. int encode_can_0x3aa_VcuCrsDstSwtPlusSts(can_obj_shenlan_h_t *o, uint8_t in) {
  1306. assert(o);
  1307. o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts = in;
  1308. return 0;
  1309. }
  1310. int print_can_0x3aa_ADC_3AA(const can_obj_shenlan_h_t *o) {
  1311. assert(o);
  1312. int r = 0;
  1313. printf("\tVcuCrsSetSwtSts = %d\r\n", (o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts));
  1314. printf("\tVcuCrsResuSwtSts = %d\r\n", (o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts));
  1315. printf("\tVcuCrsDstSwtPlusSts = %d\r\n", (o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts));
  1316. return r;
  1317. }
  1318. int unpack_message(can_obj_shenlan_h_t *o, const unsigned long id, uint64_t data, uint8_t dlc, dbcc_time_stamp_t time_stamp) {
  1319. assert(o);
  1320. assert(id < (1ul << 29)); /* 29-bit CAN ID is largest possible */
  1321. assert(dlc <= 8); /* Maximum of 8 bytes in a CAN packet */
  1322. switch (id) {
  1323. case 0x144: return unpack_can_0x144_ECU_144(o, data, dlc, time_stamp);
  1324. case 0x147: return unpack_can_0x147_ADC_147(o, data, dlc, time_stamp);
  1325. case 0x14a: return unpack_can_0x14a_ADC_14A(o, data, dlc, time_stamp);
  1326. case 0x24b: return unpack_can_0x24b_ECU_24B(o, data, dlc, time_stamp);
  1327. case 0x250: return unpack_can_0x250_ADC_250(o, data, dlc, time_stamp);
  1328. case 0x358: return unpack_can_0x358_ADC_358(o, data, dlc, time_stamp);
  1329. case 0x36e: return unpack_can_0x36e_ECU_36E(o, data, dlc, time_stamp);
  1330. case 0x3aa: return unpack_can_0x3aa_ADC_3AA(o, data, dlc, time_stamp);
  1331. default: break;
  1332. }
  1333. return -1;
  1334. }
  1335. int pack_message(can_obj_shenlan_h_t *o, const unsigned long id, uint64_t *data) {
  1336. assert(o);
  1337. assert(id < (1ul << 29)); /* 29-bit CAN ID is largest possible */
  1338. switch (id) {
  1339. case 0x144: return pack_can_0x144_ECU_144(o, data);
  1340. case 0x147: return pack_can_0x147_ADC_147(o, data);
  1341. case 0x14a: return pack_can_0x14a_ADC_14A(o, data);
  1342. case 0x24b: return pack_can_0x24b_ECU_24B(o, data);
  1343. case 0x250: return pack_can_0x250_ADC_250(o, data);
  1344. case 0x358: return pack_can_0x358_ADC_358(o, data);
  1345. case 0x36e: return pack_can_0x36e_ECU_36E(o, data);
  1346. case 0x3aa: return pack_can_0x3aa_ADC_3AA(o, data);
  1347. default: break;
  1348. }
  1349. return -1;
  1350. }
  1351. int print_message(const can_obj_shenlan_h_t *o, const unsigned long id) {
  1352. assert(o);
  1353. assert(id < (1ul << 29)); /* 29-bit CAN ID is largest possible */
  1354. switch (id) {
  1355. case 0x144: return print_can_0x144_ECU_144(o);
  1356. case 0x147: return print_can_0x147_ADC_147(o);
  1357. case 0x14a: return print_can_0x14a_ADC_14A(o);
  1358. case 0x24b: return print_can_0x24b_ECU_24B(o);
  1359. case 0x250: return print_can_0x250_ADC_250(o);
  1360. case 0x358: return print_can_0x358_ADC_358(o);
  1361. case 0x36e: return print_can_0x36e_ECU_36E(o);
  1362. case 0x3aa: return print_can_0x3aa_ADC_3AA(o);
  1363. default: break;
  1364. }
  1365. return -1;
  1366. }