Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed move4wheel2 EC CruizCore_R1370P
Diff: can/can.cpp
- Revision:
- 8:2ba338b4590e
- Parent:
- 7:44ce34007499
- Child:
- 9:7667dcfc7ce5
--- a/can/can.cpp Sat Mar 02 08:27:05 2019 +0000
+++ b/can/can.cpp Thu Mar 07 02:54:55 2019 +0000
@@ -11,11 +11,14 @@
DigitalOut cansend_led(LED1); //canread -> on
DigitalOut canread_led(LED2); //cansend -> on
+int t1_r=0, T1=0; //動作番号(受け取った値、送信する値(int型))
+
void can_readsend()
{
CANMessage msg;
if(can1.read(msg)) {
+
canread_led = 1;
if(msg.id == 1) { //from main
@@ -27,9 +30,11 @@
id1_value[4] = (msg.data[0]>>3)%4; //state of right joystick(1~3)
id1_value[5] = (msg.data[0]>>2)%2; //left joystick neutral position(0 or 1)
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]);
}
if(msg.id == 3) {
@@ -50,13 +55,20 @@
canread_led = 0;
}
- if(can1.write(CANMessage(7,can_ashileddata,1))) { //IDを7にして送信
+
+ can_ashileddata[1] = T1; //動作番号(id節約のため、can_ashileddata[]と一緒に送る)
+
+ if(can1.write(CANMessage(4,can_ashileddata,2))) { //IDを4にして送信
cansend_led = 1;
} else {
cansend_led = 0;
}
+ if(t1_r > T1) {
+ T1 = t1_r;
+ }
}
+
void can_start()
{