SolidGeek / VescUart

An Arduino library for interfacing with the VESC over UART
GNU General Public License v3.0
177 stars 92 forks source link

Adds vesc fault code readout #24

Closed BertvanRossem closed 2 years ago

BertvanRossem commented 3 years ago

Hi,

I was using your library to control my vesc, but it often went into error. With this simple change, it also reads out the mc_fault_code enum sent over, so you can check what the error is.

Thanks for your library!

BertvanRossem commented 3 years ago

I just changed the code to allow a user-definable timeout of the function. The default of 100ms is quite long with higher baud rates, so now you can set it yourself. The constructor has a default value of the old 100ms, so the code is backward compatible.

vicgwee commented 3 years ago

This is a very useful change. For my application I had to reduce the timeout value as well.

Teslafly commented 3 years ago

Is there anything stopping this from being merged?

vicgwee commented 3 years ago

I think only @SolidGeek and @VR-AntHill have write access

BertvanRossem commented 3 years ago

Thanks! I don't know why it has not been merged yet. I have not heard anything from either of them. I now just use my own, since this repo hasn't had any updates. However a merge would be nice.

Teslafly commented 2 years ago

it looks like reading the fault code has been added. https://github.com/SolidGeek/VescUart/blob/master/src/VescUart.cpp#L207

not an adjustable timeout though. not sure that's needed?

BertvanRossem commented 2 years ago

The error that is read out is put into a uint8_t, instead of the proper enum.

My code runs a pid loop at 20Hz, so if the vesc code hangs by 100ms, it screws up all the timing. Now I can change it to something like 10ms to solve that problem.