3/19 23:30
Dependencies: mbed move4wheel2 EC CruizCore_R1370P
Diff: can/can.cpp
- Revision:
- 11:9db93bce4eef
- Parent:
- 9:7667dcfc7ce5
--- a/can/can.cpp Wed Mar 13 04:23:18 2019 +0000 +++ b/can/can.cpp Tue Mar 19 02:30:34 2019 +0000 @@ -12,12 +12,15 @@ DigitalOut canread_led(LED2); //canread -> on int t1_r=0, T1=0; //動作番号(受け取った値、送信する値(int型)) +int usw_flag; void can_readsend() { CANMessage msg; + // printf("readsend\n\r"); if(can1.read(msg)) { + //printf("read\n\r"); canread_led = 1; @@ -32,12 +35,14 @@ id1_value[6] = (msg.data[0]>>1)%2; //decide right/left(0 or 1) t1_r = msg.data[3]; //value of t(0~7) - /*debug_printf("[0]=%d [1]=%d [2]=%d [3]=%d [4]=%d [5]=%d [6]=%d\n\r" - ,id1_value[0],id1_value[1],id1_value[2],id1_value[3],id1_value[4],id1_value[5],id1_value[6]);*/ - debug_printf("t1_r=%d T1=%d can_ashileddata[1]=%d\n\r",t1_r,T1,can_ashileddata[1]); + // debug_printf("[0]=%d [1]=%d [2]=%d [3]=%d [4]=%d [5]=%d [6]=%d\n\r" + // ,id1_value[0],id1_value[1],id1_value[2],id1_value[3],id1_value[4],id1_value[5],id1_value[6]); + // debug_printf("t1_r=%d T1=%d can_ashileddata[1]=%d\n\r",t1_r,T1,can_ashileddata[1]); } if(msg.id == 3) { + usw_flag = 0; + usw_data1 = 0.1 * (short)((msg.data[0]<<8) | msg.data[1]); //debug_printf("usw_data1 = %f\n\r",usw_data1); @@ -50,6 +55,8 @@ usw_data4 = 0.1 * (short)((msg.data[6]<<8) | msg.data[7]); //debug_printf("usw_data4 = %f\n\r",usw_data4); //debug_printf("usw1=%f usw2=%f usw3=%f usw4=%f\n\r",usw_data1,usw_data2,usw_data3,usw_data4); + }else{ + usw_flag = 1; } } else { @@ -60,8 +67,10 @@ can_ashileddata[1] = T1; //動作番号(id節約のため、can_ashileddata[]と一緒に送る) if(can1.write(CANMessage(4,can_ashileddata,2))) { //IDを4にして送信 + // printf("send\n\r"); cansend_led = 1; } else { + //printf("not_send\n\r"); cansend_led = 0; }