ardnew/STUSB4500

Compiling and running the demo code in Arduino IDE 1.8.12 under Windows and MacOs

misujr opened this issue · 5 comments

Hi there,
Awesome work what you did here and I would love to give it a spin but I seem to run into trouble :-) .

I am trying to compile the code for an Arduino UNO under Arduino IDE 1.8.12 on a windows 10 pc but also on MacOs Catalina with same errors .

If I try to compile the code I get first :
'class HardwareSerial' has no member named 'printf'; did you mean 'print'?

If I change all "Serial.printf" to Serial.print I get this :
C:\Users......\arduino\hardware\avr\1.8.3\cores\arduino/Print.h:72:12: note: conversion of argument 2 would be ill-formed:

C:\Users......\arduino\hardware\avr\1.8.3\cores\arduino\hardware\avr\1.8.3\cores\arduino/Print.h:73:12: note: candidate: size_t Print::print(long unsigned int, int)

 size_t print(unsigned long, int = DEC);

        ^~~~~

C:\Users......\arduino\hardware\avr\1.8.3\cores\arduino\hardware\avr\1.8.3\cores\arduino/Print.h:73:12: note: conversion of argument 2 would be ill-formed:

exit status 1
no matching function for call to 'HardwareSerial::print(const char [17], size_t&, uint16_t&, uint16_t&)'

If I try to split and print one by one the PDO number, PDO voltage and PDO current I get the same error as above .

Can you please point me in the right direction?
I have a plethora of atmel boards in my hands and I can use ATSAMD based boards also but I am unsure how to go about to get the example to compile :-D .

Thank you ,
Misujr

Just to add to the context, I have tried running the example now in platformIO also and got the same errors . I am more familiar with Arduino IDE but I wanted to give this a try just in case :-) .

Looks like Arduino Uno's (AVR) HardwareSerial class doesn't implement printf. Just need to replace those with simple print or println calls using buffered strings. Those strings can be formatted using sprintf or snprintf from the C standard library.

See my committed fix for an example.

There was another change I needed to make to this library, so I've also repackaged and updated the version to 1.0.4, which includes the fix for this example. It may take a few hours for it to show up in the Arduino Library Manager.

I've also added Troubleshooting section to the README that might help if you have further issues (version 1.0.4+1).

@misujr please reply if this fix resolved your issue, otherwise I'll auto-close this issue in 3 days (14 since last response)

@ardnew I am sorry for not coming back to you earlier. I am really grateful fo r for the swift response and action you took . The problem is on my side not being able to test. I will close now the issue as I am waiting for a few new boards that that have the STMG0 plus the ItsyBitsy form Adafruit to give it a try on them as you already tested those and work properly. In case of any other issues, I will raise a future ticket. Again really to sorry to not comeback earlier .