| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496 |
- /* Generated by DBCC, see <https://github.com/howerj/dbcc> */
- #include "shenlan.h"
- #include <inttypes.h>
- #include <assert.h>
- #define UNUSED(X) ((void)(X))
- static inline uint64_t reverse_byte_order(uint64_t x) {
- x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32;
- x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16;
- x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8;
- return x;
- }
- static inline int print_helper(int r, int print_return_value) {
- return ((r >= 0) && (print_return_value >= 0)) ? r + print_return_value : -1;
- }
- static int pack_can_0x144_ECU_144(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* ACC_LatAngReq: start-bit 4, length 14, endianess motorola, scaling 0.1, offset -720 */
- x = ((uint16_t)(o->can_0x144_ECU_144.ACC_LatAngReq)) & 0x3fff;
- x <<= 47;
- m |= x;
- /* ACC_MotorTorqueMaxLimitRequest: start-bit 21, length 11, endianess motorola, scaling 0.02, offset -20.48 */
- x = ((uint16_t)(o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest)) & 0x7ff;
- x <<= 35;
- m |= x;
- /* ACC_MotorTorqueMinLimitRequest: start-bit 26, length 11, endianess motorola, scaling 0.02, offset -20.48 */
- x = ((uint16_t)(o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest)) & 0x7ff;
- x <<= 24;
- m |= x;
- /* ADS_Reqmode: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x144_ECU_144.ADS_Reqmode)) & 0x7;
- x <<= 61;
- m |= x;
- /* ACC_ADCReqType: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x144_ECU_144.ACC_ADCReqType)) & 0x3;
- x <<= 22;
- m |= x;
- /* ACC_LatAngReqActive: start-bit 22, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x144_ECU_144.ACC_LatAngReqActive)) & 0x1;
- x <<= 46;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x144_ECU_144_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* ACC_LatAngReq: start-bit 4, length 14, endianess motorola, scaling 0.1, offset -720 */
- x = (m >> 47) & 0x3fff;
- o->can_0x144_ECU_144.ACC_LatAngReq = x;
- /* ACC_MotorTorqueMaxLimitRequest: start-bit 21, length 11, endianess motorola, scaling 0.02, offset -20.48 */
- x = (m >> 35) & 0x7ff;
- o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest = x;
- /* ACC_MotorTorqueMinLimitRequest: start-bit 26, length 11, endianess motorola, scaling 0.02, offset -20.48 */
- x = (m >> 24) & 0x7ff;
- o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest = x;
- /* ADS_Reqmode: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
- x = (m >> 61) & 0x7;
- o->can_0x144_ECU_144.ADS_Reqmode = x;
- /* ACC_ADCReqType: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 22) & 0x3;
- o->can_0x144_ECU_144.ACC_ADCReqType = x;
- /* ACC_LatAngReqActive: start-bit 22, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 46) & 0x1;
- o->can_0x144_ECU_144.ACC_LatAngReqActive = x;
- o->can_0x144_ECU_144_rx = 1;
- o->can_0x144_ECU_144_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x144_ACC_LatAngReq(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x144_ECU_144.ACC_LatAngReq);
- rval *= 0.1;
- rval += -720;
- if (rval <= 720) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x144_ACC_LatAngReq(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x144_ECU_144.ACC_LatAngReq = 0;
- if (in > 720)
- return -1;
- in += 720;
- in *= 10;
- o->can_0x144_ECU_144.ACC_LatAngReq = in;
- return 0;
- }
- int decode_can_0x144_ACC_MotorTorqueMaxLimitRequest(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest);
- rval *= 0.02;
- rval += -20.48;
- if (rval <= 20.44) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x144_ACC_MotorTorqueMaxLimitRequest(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest = 0;
- if (in > 20.44)
- return -1;
- in += 20.48;
- in *= 50;
- o->can_0x144_ECU_144.ACC_MotorTorqueMaxLimitRequest = in;
- return 0;
- }
- int decode_can_0x144_ACC_MotorTorqueMinLimitRequest(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest);
- rval *= 0.02;
- rval += -20.48;
- if (rval <= 20.44) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x144_ACC_MotorTorqueMinLimitRequest(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest = 0;
- if (in > 20.44)
- return -1;
- in += 20.48;
- in *= 50;
- o->can_0x144_ECU_144.ACC_MotorTorqueMinLimitRequest = in;
- return 0;
- }
- int decode_can_0x144_ADS_Reqmode(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x144_ECU_144.ADS_Reqmode);
- *out = rval;
- return 0;
- }
- int encode_can_0x144_ADS_Reqmode(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x144_ECU_144.ADS_Reqmode = in;
- return 0;
- }
- int decode_can_0x144_ACC_ADCReqType(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x144_ECU_144.ACC_ADCReqType);
- *out = rval;
- return 0;
- }
- int encode_can_0x144_ACC_ADCReqType(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x144_ECU_144.ACC_ADCReqType = in;
- return 0;
- }
- int decode_can_0x144_ACC_LatAngReqActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x144_ECU_144.ACC_LatAngReqActive);
- *out = rval;
- return 0;
- }
- int encode_can_0x144_ACC_LatAngReqActive(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x144_ECU_144.ACC_LatAngReqActive = in;
- return 0;
- }
- int print_can_0x144_ECU_144(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- double ACC_LatAngReq = 0.0;
- decode_can_0x144_ACC_LatAngReq(o,&ACC_LatAngReq);
- printf("\tACC_LatAngReq = %f\r\n", ACC_LatAngReq);
- double ACC_MotorTorqueMaxLimitRequest = 0.0;
- decode_can_0x144_ACC_MotorTorqueMaxLimitRequest(o,&ACC_MotorTorqueMaxLimitRequest);
- printf("\tACC_MotorTorqueMaxLimitRequest = %f\r\n", ACC_MotorTorqueMaxLimitRequest);
- double ACC_MotorTorqueMinLimitRequest = 0.0;
- decode_can_0x144_ACC_MotorTorqueMinLimitRequest(o,&ACC_MotorTorqueMinLimitRequest);
- printf("\tACC_MotorTorqueMinLimitRequest = %f\r\n", ACC_MotorTorqueMinLimitRequest);
- printf("\tADS_Reqmode = %d\r\n", (o->can_0x144_ECU_144.ADS_Reqmode));
- printf("\tACC_ADCReqType = %d\r\n", (o->can_0x144_ECU_144.ACC_ADCReqType));
- printf("\tACC_LatAngReqActive = %d\r\n", (o->can_0x144_ECU_144.ACC_LatAngReqActive));
- return r;
- }
- static int pack_can_0x147_ADC_147(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* EpsSasSteerAg: start-bit 9, length 16, endianess motorola, scaling 0.1, offset 0 */
- x = ((uint16_t)(o->can_0x147_ADC_147.EpsSasSteerAg)) & 0xffff;
- x <<= 34;
- m |= x;
- /* EPS_Pinionang: start-bit 7, length 14, endianess motorola, scaling 0.1, offset -720 */
- x = ((uint16_t)(o->can_0x147_ADC_147.EPS_Pinionang)) & 0x3fff;
- x <<= 50;
- m |= x;
- /* EspVehSpd: start-bit 41, length 13, endianess motorola, scaling 0.05625, offset 0 */
- x = ((uint16_t)(o->can_0x147_ADC_147.EspVehSpd)) & 0x1fff;
- x <<= 5;
- m |= x;
- /* EpsSteerAgRate: start-bit 24, length 8, endianess motorola, scaling 4, offset 0 */
- x = ((uint8_t)(o->can_0x147_ADC_147.EpsSteerAgRate)) & 0xff;
- x <<= 25;
- m |= x;
- /* EPS_ADS_Abortfeedback: start-bit 45, length 4, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x147_ADC_147.EPS_ADS_Abortfeedback)) & 0xf;
- x <<= 18;
- m |= x;
- /* EPS_LatCtrlAvailabilityStatus: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus)) & 0x3;
- x <<= 22;
- m |= x;
- /* EpsSasSteerAgVld: start-bit 25, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x147_ADC_147.EpsSasSteerAgVld)) & 0x1;
- x <<= 33;
- m |= x;
- /* EPS_LatCtrlActive: start-bit 32, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlActive)) & 0x1;
- x <<= 24;
- m |= x;
- /* EspVehSpdVld: start-bit 60, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x147_ADC_147.EspVehSpdVld)) & 0x1;
- x <<= 4;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x147_ADC_147_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* EpsSasSteerAg: start-bit 9, length 16, endianess motorola, scaling 0.1, offset 0 */
- x = (m >> 34) & 0xffff;
- o->can_0x147_ADC_147.EpsSasSteerAg = x;
- /* EPS_Pinionang: start-bit 7, length 14, endianess motorola, scaling 0.1, offset -720 */
- x = (m >> 50) & 0x3fff;
- o->can_0x147_ADC_147.EPS_Pinionang = x;
- /* EspVehSpd: start-bit 41, length 13, endianess motorola, scaling 0.05625, offset 0 */
- x = (m >> 5) & 0x1fff;
- o->can_0x147_ADC_147.EspVehSpd = x;
- /* EpsSteerAgRate: start-bit 24, length 8, endianess motorola, scaling 4, offset 0 */
- x = (m >> 25) & 0xff;
- o->can_0x147_ADC_147.EpsSteerAgRate = x;
- /* EPS_ADS_Abortfeedback: start-bit 45, length 4, endianess motorola, scaling 1, offset 0 */
- x = (m >> 18) & 0xf;
- o->can_0x147_ADC_147.EPS_ADS_Abortfeedback = x;
- /* EPS_LatCtrlAvailabilityStatus: start-bit 47, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 22) & 0x3;
- o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus = x;
- /* EpsSasSteerAgVld: start-bit 25, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 33) & 0x1;
- o->can_0x147_ADC_147.EpsSasSteerAgVld = x;
- /* EPS_LatCtrlActive: start-bit 32, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 24) & 0x1;
- o->can_0x147_ADC_147.EPS_LatCtrlActive = x;
- /* EspVehSpdVld: start-bit 60, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 4) & 0x1;
- o->can_0x147_ADC_147.EspVehSpdVld = x;
- o->can_0x147_ADC_147_rx = 1;
- o->can_0x147_ADC_147_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x147_EpsSasSteerAg(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x147_ADC_147.EpsSasSteerAg);
- rval *= 0.1;
- if ((rval >= -780) && (rval <= 780)) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x147_EpsSasSteerAg(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x147_ADC_147.EpsSasSteerAg = 0;
- if (in < -780)
- return -1;
- if (in > 780)
- return -1;
- in *= 10;
- o->can_0x147_ADC_147.EpsSasSteerAg = in;
- return 0;
- }
- int decode_can_0x147_EPS_Pinionang(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x147_ADC_147.EPS_Pinionang);
- rval *= 0.1;
- rval += -720;
- if (rval <= 720) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x147_EPS_Pinionang(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x147_ADC_147.EPS_Pinionang = 0;
- if (in > 720)
- return -1;
- in += 720;
- in *= 10;
- o->can_0x147_ADC_147.EPS_Pinionang = in;
- return 0;
- }
- int decode_can_0x147_EspVehSpd(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x147_ADC_147.EspVehSpd);
- rval *= 0.05625;
- if (rval <= 460.744) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x147_EspVehSpd(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x147_ADC_147.EspVehSpd = 0;
- if (in > 460.744)
- return -1;
- in *= 17.7778;
- o->can_0x147_ADC_147.EspVehSpd = in;
- return 0;
- }
- int decode_can_0x147_EpsSteerAgRate(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x147_ADC_147.EpsSteerAgRate);
- rval *= 4;
- *out = rval;
- return 0;
- }
- int encode_can_0x147_EpsSteerAgRate(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- in *= 0.25;
- o->can_0x147_ADC_147.EpsSteerAgRate = in;
- return 0;
- }
- int decode_can_0x147_EPS_ADS_Abortfeedback(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EPS_ADS_Abortfeedback);
- *out = rval;
- return 0;
- }
- int encode_can_0x147_EPS_ADS_Abortfeedback(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x147_ADC_147.EPS_ADS_Abortfeedback = in;
- return 0;
- }
- int decode_can_0x147_EPS_LatCtrlAvailabilityStatus(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus);
- *out = rval;
- return 0;
- }
- int encode_can_0x147_EPS_LatCtrlAvailabilityStatus(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus = in;
- return 0;
- }
- int decode_can_0x147_EpsSasSteerAgVld(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EpsSasSteerAgVld);
- *out = rval;
- return 0;
- }
- int encode_can_0x147_EpsSasSteerAgVld(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x147_ADC_147.EpsSasSteerAgVld = in;
- return 0;
- }
- int decode_can_0x147_EPS_LatCtrlActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EPS_LatCtrlActive);
- *out = rval;
- return 0;
- }
- int encode_can_0x147_EPS_LatCtrlActive(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x147_ADC_147.EPS_LatCtrlActive = in;
- return 0;
- }
- int decode_can_0x147_EspVehSpdVld(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x147_ADC_147.EspVehSpdVld);
- *out = rval;
- return 0;
- }
- int encode_can_0x147_EspVehSpdVld(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x147_ADC_147.EspVehSpdVld = in;
- return 0;
- }
- int print_can_0x147_ADC_147(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- double EpsSasSteerAg = 0.0;
- decode_can_0x147_EpsSasSteerAg(o,&EpsSasSteerAg);
- printf("\tEpsSasSteerAg = %f\r\n", EpsSasSteerAg);
- double EPS_Pinionang = 0.0;
- decode_can_0x147_EPS_Pinionang(o,&EPS_Pinionang);
- printf("\tEPS_Pinionang = %f\r\n", EPS_Pinionang);
- double EspVehSpd = 0.0;
- decode_can_0x147_EspVehSpd(o,&EspVehSpd);
- printf("\tEspVehSpd = %f\r\n", EspVehSpd);
- double EpsSteerAgRate = 0.0;
- decode_can_0x147_EpsSteerAgRate(o,&EpsSteerAgRate);
- printf("\tEpsSteerAgRate = %f\r\n", EpsSteerAgRate);
- printf("\tEPS_ADS_Abortfeedback = %d\r\n", (o->can_0x147_ADC_147.EPS_ADS_Abortfeedback));
- printf("\tEPS_LatCtrlAvailabilityStatus = %d\r\n", (o->can_0x147_ADC_147.EPS_LatCtrlAvailabilityStatus));
- printf("\tEpsSasSteerAgVld = %d\r\n", (o->can_0x147_ADC_147.EpsSasSteerAgVld));
- printf("\tEPS_LatCtrlActive = %d\r\n", (o->can_0x147_ADC_147.EPS_LatCtrlActive));
- printf("\tEspVehSpdVld = %d\r\n", (o->can_0x147_ADC_147.EspVehSpdVld));
- return r;
- }
- static int pack_can_0x14a_ADC_14A(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* VcuPtTqLimMax: start-bit 7, length 16, endianess motorola, scaling 1, offset -32768 */
- x = ((uint16_t)(o->can_0x14a_ADC_14A.VcuPtTqLimMax)) & 0xffff;
- x <<= 48;
- m |= x;
- /* VcuPtTqLimMin: start-bit 23, length 16, endianess motorola, scaling 1, offset -32768 */
- x = ((uint16_t)(o->can_0x14a_ADC_14A.VcuPtTqLimMin)) & 0xffff;
- x <<= 32;
- m |= x;
- /* VcuPtTqReal: start-bit 39, length 16, endianess motorola, scaling 1, offset -32768 */
- x = ((uint16_t)(o->can_0x14a_ADC_14A.VcuPtTqReal)) & 0xffff;
- x <<= 16;
- m |= x;
- /* VcuShiftLvlPosn: start-bit 50, length 4, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x14a_ADC_14A.VcuShiftLvlPosn)) & 0xf;
- x <<= 7;
- m |= x;
- /* IBCU_ReduceFuncAvail: start-bit 52, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail)) & 0x3;
- x <<= 11;
- m |= x;
- /* IBCU_FullFuncAvail: start-bit 54, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x14a_ADC_14A.IBCU_FullFuncAvail)) & 0x3;
- x <<= 13;
- m |= x;
- /* ESP_BrakeForce: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x14a_ADC_14A.ESP_BrakeForce)) & 0x1;
- x <<= 15;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x14a_ADC_14A_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* VcuPtTqLimMax: start-bit 7, length 16, endianess motorola, scaling 1, offset -32768 */
- x = (m >> 48) & 0xffff;
- o->can_0x14a_ADC_14A.VcuPtTqLimMax = x;
- /* VcuPtTqLimMin: start-bit 23, length 16, endianess motorola, scaling 1, offset -32768 */
- x = (m >> 32) & 0xffff;
- o->can_0x14a_ADC_14A.VcuPtTqLimMin = x;
- /* VcuPtTqReal: start-bit 39, length 16, endianess motorola, scaling 1, offset -32768 */
- x = (m >> 16) & 0xffff;
- o->can_0x14a_ADC_14A.VcuPtTqReal = x;
- /* VcuShiftLvlPosn: start-bit 50, length 4, endianess motorola, scaling 1, offset 0 */
- x = (m >> 7) & 0xf;
- o->can_0x14a_ADC_14A.VcuShiftLvlPosn = x;
- /* IBCU_ReduceFuncAvail: start-bit 52, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 11) & 0x3;
- o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail = x;
- /* IBCU_FullFuncAvail: start-bit 54, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 13) & 0x3;
- o->can_0x14a_ADC_14A.IBCU_FullFuncAvail = x;
- /* ESP_BrakeForce: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 15) & 0x1;
- o->can_0x14a_ADC_14A.ESP_BrakeForce = x;
- o->can_0x14a_ADC_14A_rx = 1;
- o->can_0x14a_ADC_14A_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x14a_VcuPtTqLimMax(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x14a_ADC_14A.VcuPtTqLimMax);
- rval += -32768;
- if (rval <= 32767) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x14a_VcuPtTqLimMax(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x14a_ADC_14A.VcuPtTqLimMax = 0;
- if (in > 32767)
- return -1;
- in += 32768;
- o->can_0x14a_ADC_14A.VcuPtTqLimMax = in;
- return 0;
- }
- int decode_can_0x14a_VcuPtTqLimMin(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x14a_ADC_14A.VcuPtTqLimMin);
- rval += -32768;
- if (rval <= 32767) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x14a_VcuPtTqLimMin(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x14a_ADC_14A.VcuPtTqLimMin = 0;
- if (in > 32767)
- return -1;
- in += 32768;
- o->can_0x14a_ADC_14A.VcuPtTqLimMin = in;
- return 0;
- }
- int decode_can_0x14a_VcuPtTqReal(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x14a_ADC_14A.VcuPtTqReal);
- rval += -32768;
- if (rval <= 32767) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x14a_VcuPtTqReal(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x14a_ADC_14A.VcuPtTqReal = 0;
- if (in > 32767)
- return -1;
- in += 32768;
- o->can_0x14a_ADC_14A.VcuPtTqReal = in;
- return 0;
- }
- int decode_can_0x14a_VcuShiftLvlPosn(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.VcuShiftLvlPosn);
- *out = rval;
- return 0;
- }
- int encode_can_0x14a_VcuShiftLvlPosn(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x14a_ADC_14A.VcuShiftLvlPosn = in;
- return 0;
- }
- int decode_can_0x14a_IBCU_ReduceFuncAvail(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail);
- *out = rval;
- return 0;
- }
- int encode_can_0x14a_IBCU_ReduceFuncAvail(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail = in;
- return 0;
- }
- int decode_can_0x14a_IBCU_FullFuncAvail(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.IBCU_FullFuncAvail);
- *out = rval;
- return 0;
- }
- int encode_can_0x14a_IBCU_FullFuncAvail(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x14a_ADC_14A.IBCU_FullFuncAvail = in;
- return 0;
- }
- int decode_can_0x14a_ESP_BrakeForce(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x14a_ADC_14A.ESP_BrakeForce);
- *out = rval;
- return 0;
- }
- int encode_can_0x14a_ESP_BrakeForce(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x14a_ADC_14A.ESP_BrakeForce = in;
- return 0;
- }
- int print_can_0x14a_ADC_14A(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- double VcuPtTqLimMax = 0.0;
- decode_can_0x14a_VcuPtTqLimMax(o,&VcuPtTqLimMax);
- printf("\tVcuPtTqLimMax = %f\r\n", VcuPtTqLimMax);
- double VcuPtTqLimMin = 0.0;
- decode_can_0x14a_VcuPtTqLimMin(o,&VcuPtTqLimMin);
- printf("\tVcuPtTqLimMin = %f\r\n", VcuPtTqLimMin);
- double VcuPtTqReal = 0.0;
- decode_can_0x14a_VcuPtTqReal(o,&VcuPtTqReal);
- printf("\tVcuPtTqReal = %f\r\n", VcuPtTqReal);
- printf("\tVcuShiftLvlPosn = %d\r\n", (o->can_0x14a_ADC_14A.VcuShiftLvlPosn));
- printf("\tIBCU_ReduceFuncAvail = %d\r\n", (o->can_0x14a_ADC_14A.IBCU_ReduceFuncAvail));
- printf("\tIBCU_FullFuncAvail = %d\r\n", (o->can_0x14a_ADC_14A.IBCU_FullFuncAvail));
- printf("\tESP_BrakeForce = %d\r\n", (o->can_0x14a_ADC_14A.ESP_BrakeForce));
- return r;
- }
- static int pack_can_0x24b_ECU_24B(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* ACC_AEBTargetDeceleration: start-bit 24, length 16, endianess motorola, scaling 0.0005, offset -16 */
- x = ((uint16_t)(o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration)) & 0xffff;
- x <<= 17;
- m |= x;
- /* ACC_AccTrqReq: start-bit 7, length 15, endianess motorola, scaling 1, offset -16384 */
- x = ((uint16_t)(o->can_0x24b_ECU_24B.ACC_AccTrqReq)) & 0x7fff;
- x <<= 49;
- m |= x;
- /* ACC_ACCTargetAcceleration: start-bit 20, length 8, endianess motorola, scaling 0.05, offset -10 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration)) & 0xff;
- x <<= 37;
- m |= x;
- /* ACC_ACCMode: start-bit 58, length 3, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_ACCMode)) & 0x7;
- m |= x;
- /* ADCReqMode: start-bit 50, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ADCReqMode)) & 0x3;
- x <<= 9;
- m |= x;
- /* ACC_AccTrqReqActive: start-bit 8, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_AccTrqReqActive)) & 0x1;
- x <<= 48;
- m |= x;
- /* ACC_AEBVehilceHoldReq: start-bit 40, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq)) & 0x1;
- x <<= 16;
- m |= x;
- /* ACC_AEBActive: start-bit 51, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBActive)) & 0x1;
- x <<= 11;
- m |= x;
- /* ACC_Driveoff_Request: start-bit 53, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_Driveoff_Request)) & 0x1;
- x <<= 13;
- m |= x;
- /* ACC_DecToStop: start-bit 54, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_DecToStop)) & 0x1;
- x <<= 14;
- m |= x;
- /* ACC_CDDActive: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x24b_ECU_24B.ACC_CDDActive)) & 0x1;
- x <<= 15;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x24b_ECU_24B_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* ACC_AEBTargetDeceleration: start-bit 24, length 16, endianess motorola, scaling 0.0005, offset -16 */
- x = (m >> 17) & 0xffff;
- o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration = x;
- /* ACC_AccTrqReq: start-bit 7, length 15, endianess motorola, scaling 1, offset -16384 */
- x = (m >> 49) & 0x7fff;
- o->can_0x24b_ECU_24B.ACC_AccTrqReq = x;
- /* ACC_ACCTargetAcceleration: start-bit 20, length 8, endianess motorola, scaling 0.05, offset -10 */
- x = (m >> 37) & 0xff;
- o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration = x;
- /* ACC_ACCMode: start-bit 58, length 3, endianess motorola, scaling 1, offset 0 */
- x = m & 0x7;
- o->can_0x24b_ECU_24B.ACC_ACCMode = x;
- /* ADCReqMode: start-bit 50, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 9) & 0x3;
- o->can_0x24b_ECU_24B.ADCReqMode = x;
- /* ACC_AccTrqReqActive: start-bit 8, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 48) & 0x1;
- o->can_0x24b_ECU_24B.ACC_AccTrqReqActive = x;
- /* ACC_AEBVehilceHoldReq: start-bit 40, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 16) & 0x1;
- o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq = x;
- /* ACC_AEBActive: start-bit 51, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 11) & 0x1;
- o->can_0x24b_ECU_24B.ACC_AEBActive = x;
- /* ACC_Driveoff_Request: start-bit 53, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 13) & 0x1;
- o->can_0x24b_ECU_24B.ACC_Driveoff_Request = x;
- /* ACC_DecToStop: start-bit 54, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 14) & 0x1;
- o->can_0x24b_ECU_24B.ACC_DecToStop = x;
- /* ACC_CDDActive: start-bit 55, length 1, endianess motorola, scaling 1, offset 0 */
- x = (m >> 15) & 0x1;
- o->can_0x24b_ECU_24B.ACC_CDDActive = x;
- o->can_0x24b_ECU_24B_rx = 1;
- o->can_0x24b_ECU_24B_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x24b_ACC_AEBTargetDeceleration(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration);
- rval *= 0.0005;
- rval += -16;
- if (rval <= 16) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x24b_ACC_AEBTargetDeceleration(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration = 0;
- if (in > 16)
- return -1;
- in += 16;
- in *= 2000;
- o->can_0x24b_ECU_24B.ACC_AEBTargetDeceleration = in;
- return 0;
- }
- int decode_can_0x24b_ACC_AccTrqReq(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x24b_ECU_24B.ACC_AccTrqReq);
- rval += -16384;
- if (rval <= 16383) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x24b_ACC_AccTrqReq(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_AccTrqReq = 0;
- if (in > 16383)
- return -1;
- in += 16384;
- o->can_0x24b_ECU_24B.ACC_AccTrqReq = in;
- return 0;
- }
- int decode_can_0x24b_ACC_ACCTargetAcceleration(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration);
- rval *= 0.05;
- rval += -10;
- if (rval <= 2.75) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x24b_ACC_ACCTargetAcceleration(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration = 0;
- if (in > 2.75)
- return -1;
- in += 10;
- in *= 20;
- o->can_0x24b_ECU_24B.ACC_ACCTargetAcceleration = in;
- return 0;
- }
- int decode_can_0x24b_ACC_ACCMode(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_ACCMode);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ACC_ACCMode(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_ACCMode = in;
- return 0;
- }
- int decode_can_0x24b_ADCReqMode(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ADCReqMode);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ADCReqMode(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ADCReqMode = in;
- return 0;
- }
- int decode_can_0x24b_ACC_AccTrqReqActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_AccTrqReqActive);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ACC_AccTrqReqActive(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_AccTrqReqActive = in;
- return 0;
- }
- int decode_can_0x24b_ACC_AEBVehilceHoldReq(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ACC_AEBVehilceHoldReq(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq = in;
- return 0;
- }
- int decode_can_0x24b_ACC_AEBActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_AEBActive);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ACC_AEBActive(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_AEBActive = in;
- return 0;
- }
- int decode_can_0x24b_ACC_Driveoff_Request(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_Driveoff_Request);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ACC_Driveoff_Request(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_Driveoff_Request = in;
- return 0;
- }
- int decode_can_0x24b_ACC_DecToStop(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_DecToStop);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ACC_DecToStop(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_DecToStop = in;
- return 0;
- }
- int decode_can_0x24b_ACC_CDDActive(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x24b_ECU_24B.ACC_CDDActive);
- *out = rval;
- return 0;
- }
- int encode_can_0x24b_ACC_CDDActive(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x24b_ECU_24B.ACC_CDDActive = in;
- return 0;
- }
- int print_can_0x24b_ECU_24B(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- double ACC_AEBTargetDeceleration = 0.0;
- decode_can_0x24b_ACC_AEBTargetDeceleration(o,&ACC_AEBTargetDeceleration);
- printf("\tACC_AEBTargetDeceleration = %f\r\n", ACC_AEBTargetDeceleration);
- double ACC_AccTrqReq = 0.0;
- decode_can_0x24b_ACC_AccTrqReq(o,&ACC_AccTrqReq);
- printf("\tACC_AccTrqReq = %f\r\n", ACC_AccTrqReq);
- double ACC_ACCTargetAcceleration = 0.0;
- decode_can_0x24b_ACC_ACCTargetAcceleration(o,&ACC_ACCTargetAcceleration);
- printf("\tACC_ACCTargetAcceleration = %f\r\n", ACC_ACCTargetAcceleration);
- printf("\tACC_ACCMode = %d\r\n", (o->can_0x24b_ECU_24B.ACC_ACCMode));
- printf("\tADCReqMode = %d\r\n", (o->can_0x24b_ECU_24B.ADCReqMode));
- printf("\tACC_AccTrqReqActive = %d\r\n", (o->can_0x24b_ECU_24B.ACC_AccTrqReqActive));
- printf("\tACC_AEBVehilceHoldReq = %d\r\n", (o->can_0x24b_ECU_24B.ACC_AEBVehilceHoldReq));
- printf("\tACC_AEBActive = %d\r\n", (o->can_0x24b_ECU_24B.ACC_AEBActive));
- printf("\tACC_Driveoff_Request = %d\r\n", (o->can_0x24b_ECU_24B.ACC_Driveoff_Request));
- printf("\tACC_DecToStop = %d\r\n", (o->can_0x24b_ECU_24B.ACC_DecToStop));
- printf("\tACC_CDDActive = %d\r\n", (o->can_0x24b_ECU_24B.ACC_CDDActive));
- return r;
- }
- static int pack_can_0x250_ADC_250(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* ESP_YawRate: start-bit 2, length 14, endianess motorola, scaling 0.01, offset -81.91 */
- x = ((uint16_t)(o->can_0x250_ADC_250.ESP_YawRate)) & 0x3fff;
- x <<= 45;
- m |= x;
- /* ESP_LongAccel: start-bit 20, length 10, endianess motorola, scaling 0.03125, offset -16 */
- x = ((uint16_t)(o->can_0x250_ADC_250.ESP_LongAccel)) & 0x3ff;
- x <<= 35;
- m |= x;
- /* ESP_LatAccel: start-bit 24, length 8, endianess motorola, scaling 0.1, offset -12.7 */
- x = ((uint8_t)(o->can_0x250_ADC_250.ESP_LatAccel)) & 0xff;
- x <<= 25;
- m |= x;
- /* EPS_ADS_ControlFeedback: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x250_ADC_250.EPS_ADS_ControlFeedback)) & 0x7;
- x <<= 61;
- m |= x;
- /* ESP_YawRateValid: start-bit 4, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x250_ADC_250.ESP_YawRateValid)) & 0x3;
- x <<= 59;
- m |= x;
- /* ESP_LongAccelValid: start-bit 26, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x250_ADC_250.ESP_LongAccelValid)) & 0x3;
- x <<= 33;
- m |= x;
- /* ESP_LatAccelValid: start-bit 32, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x250_ADC_250.ESP_LatAccelValid)) & 0x3;
- x <<= 23;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x250_ADC_250_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* ESP_YawRate: start-bit 2, length 14, endianess motorola, scaling 0.01, offset -81.91 */
- x = (m >> 45) & 0x3fff;
- o->can_0x250_ADC_250.ESP_YawRate = x;
- /* ESP_LongAccel: start-bit 20, length 10, endianess motorola, scaling 0.03125, offset -16 */
- x = (m >> 35) & 0x3ff;
- o->can_0x250_ADC_250.ESP_LongAccel = x;
- /* ESP_LatAccel: start-bit 24, length 8, endianess motorola, scaling 0.1, offset -12.7 */
- x = (m >> 25) & 0xff;
- o->can_0x250_ADC_250.ESP_LatAccel = x;
- /* EPS_ADS_ControlFeedback: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
- x = (m >> 61) & 0x7;
- o->can_0x250_ADC_250.EPS_ADS_ControlFeedback = x;
- /* ESP_YawRateValid: start-bit 4, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 59) & 0x3;
- o->can_0x250_ADC_250.ESP_YawRateValid = x;
- /* ESP_LongAccelValid: start-bit 26, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 33) & 0x3;
- o->can_0x250_ADC_250.ESP_LongAccelValid = x;
- /* ESP_LatAccelValid: start-bit 32, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 23) & 0x3;
- o->can_0x250_ADC_250.ESP_LatAccelValid = x;
- o->can_0x250_ADC_250_rx = 1;
- o->can_0x250_ADC_250_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x250_ESP_YawRate(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x250_ADC_250.ESP_YawRate);
- rval *= 0.01;
- rval += -81.91;
- if (rval <= 81.92) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x250_ESP_YawRate(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x250_ADC_250.ESP_YawRate = 0;
- if (in > 81.92)
- return -1;
- in += 81.91;
- in *= 100;
- o->can_0x250_ADC_250.ESP_YawRate = in;
- return 0;
- }
- int decode_can_0x250_ESP_LongAccel(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x250_ADC_250.ESP_LongAccel);
- rval *= 0.03125;
- rval += -16;
- if (rval <= 15.9062) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x250_ESP_LongAccel(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x250_ADC_250.ESP_LongAccel = 0;
- if (in > 15.9062)
- return -1;
- in += 16;
- in *= 32;
- o->can_0x250_ADC_250.ESP_LongAccel = in;
- return 0;
- }
- int decode_can_0x250_ESP_LatAccel(const can_obj_shenlan_h_t *o, double *out) {
- assert(o);
- assert(out);
- double rval = (double)(o->can_0x250_ADC_250.ESP_LatAccel);
- rval *= 0.1;
- rval += -12.7;
- if (rval <= 12.7) {
- *out = rval;
- return 0;
- } else {
- *out = (double)0;
- return -1;
- }
- }
- int encode_can_0x250_ESP_LatAccel(can_obj_shenlan_h_t *o, double in) {
- assert(o);
- o->can_0x250_ADC_250.ESP_LatAccel = 0;
- if (in > 12.7)
- return -1;
- in += 12.7;
- in *= 10;
- o->can_0x250_ADC_250.ESP_LatAccel = in;
- return 0;
- }
- int decode_can_0x250_EPS_ADS_ControlFeedback(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.EPS_ADS_ControlFeedback);
- *out = rval;
- return 0;
- }
- int encode_can_0x250_EPS_ADS_ControlFeedback(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x250_ADC_250.EPS_ADS_ControlFeedback = in;
- return 0;
- }
- int decode_can_0x250_ESP_YawRateValid(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.ESP_YawRateValid);
- *out = rval;
- return 0;
- }
- int encode_can_0x250_ESP_YawRateValid(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x250_ADC_250.ESP_YawRateValid = in;
- return 0;
- }
- int decode_can_0x250_ESP_LongAccelValid(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.ESP_LongAccelValid);
- *out = rval;
- return 0;
- }
- int encode_can_0x250_ESP_LongAccelValid(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x250_ADC_250.ESP_LongAccelValid = in;
- return 0;
- }
- int decode_can_0x250_ESP_LatAccelValid(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x250_ADC_250.ESP_LatAccelValid);
- *out = rval;
- return 0;
- }
- int encode_can_0x250_ESP_LatAccelValid(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x250_ADC_250.ESP_LatAccelValid = in;
- return 0;
- }
- int print_can_0x250_ADC_250(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- double ESP_YawRate = 0.0;
- decode_can_0x250_ESP_YawRate(o,&ESP_YawRate);
- printf("\tESP_YawRate = %f\r\n", ESP_YawRate);
- double ESP_LongAccel = 0.0;
- decode_can_0x250_ESP_LongAccel(o,&ESP_LongAccel);
- printf("\tESP_LongAccel = %f\r\n", ESP_LongAccel);
- double ESP_LatAccel = 0.0;
- decode_can_0x250_ESP_LatAccel(o,&ESP_LatAccel);
- printf("\tESP_LatAccel = %f\r\n", ESP_LatAccel);
- printf("\tEPS_ADS_ControlFeedback = %d\r\n", (o->can_0x250_ADC_250.EPS_ADS_ControlFeedback));
- printf("\tESP_YawRateValid = %d\r\n", (o->can_0x250_ADC_250.ESP_YawRateValid));
- printf("\tESP_LongAccelValid = %d\r\n", (o->can_0x250_ADC_250.ESP_LongAccelValid));
- printf("\tESP_LatAccelValid = %d\r\n", (o->can_0x250_ADC_250.ESP_LatAccelValid));
- return r;
- }
- static int pack_can_0x358_ADC_358(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* ADS_UDLCTurnLightReq: start-bit 26, length 3, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x358_ADC_358.ADS_UDLCTurnLightReq)) & 0x7;
- x <<= 32;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x358_ADC_358_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* ADS_UDLCTurnLightReq: start-bit 26, length 3, endianess motorola, scaling 1, offset 0 */
- x = (m >> 32) & 0x7;
- o->can_0x358_ADC_358.ADS_UDLCTurnLightReq = x;
- o->can_0x358_ADC_358_rx = 1;
- o->can_0x358_ADC_358_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x358_ADS_UDLCTurnLightReq(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x358_ADC_358.ADS_UDLCTurnLightReq);
- *out = rval;
- return 0;
- }
- int encode_can_0x358_ADS_UDLCTurnLightReq(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x358_ADC_358.ADS_UDLCTurnLightReq = in;
- return 0;
- }
- int print_can_0x358_ADC_358(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- printf("\tADS_UDLCTurnLightReq = %d\r\n", (o->can_0x358_ADC_358.ADS_UDLCTurnLightReq));
- return r;
- }
- static int pack_can_0x36e_ECU_36E(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* ADS_UDLCTurnLightReq: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq)) & 0x7;
- x <<= 61;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x36e_ECU_36E_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* ADS_UDLCTurnLightReq: start-bit 7, length 3, endianess motorola, scaling 1, offset 0 */
- x = (m >> 61) & 0x7;
- o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq = x;
- o->can_0x36e_ECU_36E_rx = 1;
- o->can_0x36e_ECU_36E_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x36e_ADS_UDLCTurnLightReq(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq);
- *out = rval;
- return 0;
- }
- int encode_can_0x36e_ADS_UDLCTurnLightReq(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq = in;
- return 0;
- }
- int print_can_0x36e_ECU_36E(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- printf("\tADS_UDLCTurnLightReq = %d\r\n", (o->can_0x36e_ECU_36E.ADS_UDLCTurnLightReq));
- return r;
- }
- static int pack_can_0x3aa_ADC_3AA(can_obj_shenlan_h_t *o, uint64_t *data) {
- assert(o);
- assert(data);
- register uint64_t x;
- register uint64_t m = 0;
- /* VcuCrsSetSwtSts: start-bit 3, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts)) & 0x3;
- x <<= 58;
- m |= x;
- /* VcuCrsResuSwtSts: start-bit 5, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts)) & 0x3;
- x <<= 60;
- m |= x;
- /* VcuCrsDstSwtPlusSts: start-bit 7, length 2, endianess motorola, scaling 1, offset 0 */
- x = ((uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts)) & 0x3;
- x <<= 62;
- m |= x;
- *data = reverse_byte_order(m);
- o->can_0x3aa_ADC_3AA_tx = 1;
- return 0;
- }
- 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) {
- assert(o);
- assert(dlc <= 8);
- register uint64_t x;
- register uint64_t m = reverse_byte_order(data);
- if (dlc < 8)
- return -1;
- /* VcuCrsSetSwtSts: start-bit 3, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 58) & 0x3;
- o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts = x;
- /* VcuCrsResuSwtSts: start-bit 5, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 60) & 0x3;
- o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts = x;
- /* VcuCrsDstSwtPlusSts: start-bit 7, length 2, endianess motorola, scaling 1, offset 0 */
- x = (m >> 62) & 0x3;
- o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts = x;
- o->can_0x3aa_ADC_3AA_rx = 1;
- o->can_0x3aa_ADC_3AA_time_stamp_rx = time_stamp;
- return 0;
- }
- int decode_can_0x3aa_VcuCrsSetSwtSts(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts);
- *out = rval;
- return 0;
- }
- int encode_can_0x3aa_VcuCrsSetSwtSts(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts = in;
- return 0;
- }
- int decode_can_0x3aa_VcuCrsResuSwtSts(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts);
- *out = rval;
- return 0;
- }
- int encode_can_0x3aa_VcuCrsResuSwtSts(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts = in;
- return 0;
- }
- int decode_can_0x3aa_VcuCrsDstSwtPlusSts(const can_obj_shenlan_h_t *o, uint8_t *out) {
- assert(o);
- assert(out);
- uint8_t rval = (uint8_t)(o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts);
- *out = rval;
- return 0;
- }
- int encode_can_0x3aa_VcuCrsDstSwtPlusSts(can_obj_shenlan_h_t *o, uint8_t in) {
- assert(o);
- o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts = in;
- return 0;
- }
- int print_can_0x3aa_ADC_3AA(const can_obj_shenlan_h_t *o) {
- assert(o);
- int r = 0;
- printf("\tVcuCrsSetSwtSts = %d\r\n", (o->can_0x3aa_ADC_3AA.VcuCrsSetSwtSts));
- printf("\tVcuCrsResuSwtSts = %d\r\n", (o->can_0x3aa_ADC_3AA.VcuCrsResuSwtSts));
- printf("\tVcuCrsDstSwtPlusSts = %d\r\n", (o->can_0x3aa_ADC_3AA.VcuCrsDstSwtPlusSts));
- return r;
- }
- 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) {
- assert(o);
- assert(id < (1ul << 29)); /* 29-bit CAN ID is largest possible */
- assert(dlc <= 8); /* Maximum of 8 bytes in a CAN packet */
- switch (id) {
- case 0x144: return unpack_can_0x144_ECU_144(o, data, dlc, time_stamp);
- case 0x147: return unpack_can_0x147_ADC_147(o, data, dlc, time_stamp);
- case 0x14a: return unpack_can_0x14a_ADC_14A(o, data, dlc, time_stamp);
- case 0x24b: return unpack_can_0x24b_ECU_24B(o, data, dlc, time_stamp);
- case 0x250: return unpack_can_0x250_ADC_250(o, data, dlc, time_stamp);
- case 0x358: return unpack_can_0x358_ADC_358(o, data, dlc, time_stamp);
- case 0x36e: return unpack_can_0x36e_ECU_36E(o, data, dlc, time_stamp);
- case 0x3aa: return unpack_can_0x3aa_ADC_3AA(o, data, dlc, time_stamp);
- default: break;
- }
- return -1;
- }
- int pack_message(can_obj_shenlan_h_t *o, const unsigned long id, uint64_t *data) {
- assert(o);
- assert(id < (1ul << 29)); /* 29-bit CAN ID is largest possible */
- switch (id) {
- case 0x144: return pack_can_0x144_ECU_144(o, data);
- case 0x147: return pack_can_0x147_ADC_147(o, data);
- case 0x14a: return pack_can_0x14a_ADC_14A(o, data);
- case 0x24b: return pack_can_0x24b_ECU_24B(o, data);
- case 0x250: return pack_can_0x250_ADC_250(o, data);
- case 0x358: return pack_can_0x358_ADC_358(o, data);
- case 0x36e: return pack_can_0x36e_ECU_36E(o, data);
- case 0x3aa: return pack_can_0x3aa_ADC_3AA(o, data);
- default: break;
- }
- return -1;
- }
- int print_message(const can_obj_shenlan_h_t *o, const unsigned long id) {
- assert(o);
- assert(id < (1ul << 29)); /* 29-bit CAN ID is largest possible */
- switch (id) {
- case 0x144: return print_can_0x144_ECU_144(o);
- case 0x147: return print_can_0x147_ADC_147(o);
- case 0x14a: return print_can_0x14a_ADC_14A(o);
- case 0x24b: return print_can_0x24b_ECU_24B(o);
- case 0x250: return print_can_0x250_ADC_250(o);
- case 0x358: return print_can_0x358_ADC_358(o);
- case 0x36e: return print_can_0x36e_ECU_36E(o);
- case 0x3aa: return print_can_0x3aa_ADC_3AA(o);
- default: break;
- }
- return -1;
- }
|