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
Diff: main.cpp
- Revision:
- 1:1f21cff06302
- Parent:
- 0:4143c439ad0e
- Child:
- 2:f10d06f31141
--- a/main.cpp Fri Mar 05 08:39:56 2021 +0000 +++ b/main.cpp Wed Mar 17 17:54:54 2021 +0000 @@ -17,7 +17,7 @@ CAN can(PA_11, PA_12); // motor number -int m_num = 9; +int m_num = 16; // from a master computer int i=0; @@ -59,10 +59,6 @@ int data1 = (msg.data[2] << 8) + msg.data[3]; // current int data2 = (msg.data[4] << 8) + msg.data[5]; // velocity int data3 = (msg.data[6] << 8) + msg.data[7]; // angle - if (rid == 6){ //id=6からはyaw角度ではなくリニアPOTを受信 - //int front_linear_pot = ((msg.data[6] << 8) + msg.data[7])/100; // linear_pot data - //data3 = front_linear_pot; - } pc.printf("%d,%d,%d,%d\r\n", rid, data1, data2, data3); } } @@ -98,7 +94,7 @@ // send(ID, mode(0), dir(0 or 1), 3rd digit, 2rd digit, 1rd digit) if (buf[i-5] == 'A'){ //if (buf[i-4]-0x30==4){ //id=4には前部リニアPOTの値を送信 - send(buf[i-4]-0x30,0,0,buf[i-3],buf[i-2],buf[i-1]); + send(buf[i-4]-0x30,2,0,buf[i-3],buf[i-2],buf[i-1]); //} // ***** Receive mode (single data) ***** @@ -119,7 +115,7 @@ buf[i-1] = (char)(t3); send(buf[i-4]-0x30,0,0,buf[i-3],buf[i-2],buf[i-1]); }else{*/ - send(buf[i-4]-0x30,0,0,buf[i-3],buf[i-2],buf[i-1]); + send(buf[i-4]-0x30,0,0,buf[i-3],buf[i-2],buf[i-1]); //} //send(buf[i-4]-0x30,0,0,buf[i-3],buf[i-2],buf[i-1]); // ***** Speed control mode (negative) ***** @@ -132,7 +128,7 @@ } else if (buf[i-5] == 'E') { //id = buf[i-4]-0x30; //m_num = ((int)buf[i-3]-0x30)*100+((int)buf[i-2]-0x30)*10+(int)buf[i-1]-0x30; // Convert from String to Int; - id = ((int)buf[i-3]-0x30)*100+((int)buf[i-2]-0x30)*10+(int)buf[i-1]-0x30; // Convert from String to Int; + //id = ((int)buf[i-3]-0x30)*100+((int)buf[i-2]-0x30)*10+(int)buf[i-1]-0x30; // Convert from String to Int; flag = 1; // ***** Receive mode stop (continuous data) *****