Closed imartinezl closed 5 years ago
HI,
Just reviewed your changes. Thanks for charring your work. I've a remark to it:
The way you did it we loose the backwards compatibility. It would be great if you can add an function overloading to the functions, so that we have once the old version and also the newer one. That brings in the backwards compatibility on the one hand and compatibility for Arduinos with only one Hardware Serial.
In the switch-case in theint ReceiveUartMessage(uint8_t* payloadReceived, int num)
you should only add
case 0: serial=&Serial; break;
Then you can add to all functions ass example
bool VescUartGetValue(bldcMeasure& values) {
return VescUartGetValue(bldcMeasures, 0);
}
Can you add that to all functions? I will not find the time for in short term.
Thx in Advance
Andy
I changed the functions to allow backwards compatibility. Tell me any other changes that you find necessary.
Please remain patient. I will merge your pull request as soon, as I can find the time. Sorry for the delay.
Hi,
Just tried to compile it for a Nano with my project ArduBoardControl. It throws a bunch of errors:
`Compiling 'ArduBoardControler_Rx' for 'Arduino Nano w/ ATmega328'
VescUart.cpp: In function int ReceiveUartMessage(uint8_t*, int)
Error compiling libraries Build failed for project 'ArduBoardControler_Rx' VescUart.cpp: 43:12: error: 'Serial1' was not declared in this scope serial=&Serial1
VescUart.cpp: 46:12: error: 'Serial2' was not declared in this scope serial=&Serial2
VescUart.cpp: 49:12: error: 'Serial3' was not declared in this scope serial=&Serial3
VescUart.cpp: In function int PackSendPayload(uint8_t*, int, int)
VescUart.cpp: 173:12: error: 'Serial1' was not declared in this scope serial=&Serial1
VescUart.cpp: 176:12: error: 'Serial2' was not declared in this scope serial=&Serial2
VescUart.cpp: 179:12: error: 'Serial3' was not declared in this scope serial=&Serial3
VescUart.cpp: In function bool VescUartGetValue(bldcMeasure&)
VescUart.cpp: 240:45: error: expected identifier before numeric constant bool VescUartGetValue(bldcMeasure& values, 0)
VescUart.cpp: 240:45: error: expected ',' or '...' before numeric constant VescUart.cpp: At global scope
VescUart.cpp: 244:21: error: 'posMeasure' was not declared in this scope bool VescUartGetPPM(posMeasure& values2, int num) {
VescUart.cpp: 244:33: error: 'values2' was not declared in this scope bool VescUartGetPPM(posMeasure& values2, int num) {
VescUart.cpp: 244:42: error: expected primary-expression before 'int bool VescUartGetPPM(posMeasure& values2, int num) {
VescUart.cpp: 244:49: error: expression list treated as compound expression in initializer [-fpermissive] bool VescUartGetPPM(posMeasure& values2, int num) {
VescUart.cpp: 244:51: error: expected ',' or ';' before '{' token bool VescUartGetPPM(posMeasure& values2, int num) {`
It is required to put all Serial1-3 Stuff in an ifdef. Please test it with: ArduBoarControl
Hi,
Just fixed the Arduino Nano compatibility and the previous errors. I tested the library by compiling 'ArduBoardControler_Rx' for 'Arduino Nano w/ ATmega328' and also for 'Arduino Mega w/ ATmega2560'. Hope everything works fine now:)
Please test again. I made minor changes. In the config.h you will find define MULTI_SERIAL. Ifdef changed accordingly. I think this way we provide better adaptability to other processors as well. You will find the changes on the branch: https://github.com/RollingGecko/VescUartControl/tree/imartinezl-master
OK. Found one more bug and a refactoring. Please wait for test.
Hi there:) Do you want me to test it again?
I changed the design of multi Serials. Need some time to find one more bug on it. Sorry.
Hi,
Long time passed. Now finally I was able to bring it all in line and provide a new Version I would ask you to test. Please check out: https://github.com/RollingGecko/VescUartControl/tree/imartinezl-master
You will see that there is now a setSerialPort function included. I think this is the cleanest design. You also don't need to toggle DebugSerial it the library anymore. It is now in an #ifdef if a DebugSerialPort is defined. At the moment I've no chance to test it. So if you can verify, that it is works, I can merge it to the master.
Andy
Hi Andy,
I've just tested the new version of the library. Everything works perfectly, I believe this is ready to merge. Thank you for cleaning the code and making it easier to understand.
Best! Iñigo
Hy guys, I'm using that libraries for a while now. We are prototyping this product with vesc : https://www.facebook.com/kitewinder/
I also added Set RPM function by myself, working fine. I am now trying to had position control mode. it seems to works, but nevermind the value I put in, it works for position 0 only. for example : VescUartSetPos(0 ) or VescUartSetPos(0,5 ) or VescUartSetPos(120) -> the motor will just hold position 0. Any idea where this could come from ?
New functions added to the UART communication with the VESC:
Compatibility with up to 3 VESC controllers connected to the same Arduino Mega All functions have been modified to indicate the Serial to communicate with, through a integer variable (num)