Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with HardwareSerial on Arduino DUE #38

Open
Berry07 opened this issue May 29, 2016 · 1 comment
Open

Problems with HardwareSerial on Arduino DUE #38

Berry07 opened this issue May 29, 2016 · 1 comment

Comments

@Berry07
Copy link

Berry07 commented May 29, 2016

Great work, I am using Your Sketch on a Mega for my Home Automation and it works fine, Thank You for that.
But now I wanted to port it to a DUE, because the Mega is running out of Speed.
I have problems compiling Your Sketch on my DUE causing a HardwareSerial error.

Working on a MAC Version 10.11.2, Arduino 1.65 gives this error:

Arduino:` 1.6.5 (Mac OS X), Platine: "Arduino Due (Programming Port)"

ModbusSensor.cpp: In member function 'void modbusMaster::begin(uint16_t, uint8_t)':
ModbusSensor.cpp:205: error: no matching function for call to 'HardwareSerial::begin(uint16_t&, uint8_t&)'
(__hwSerial).begin(baudrate, byteFormat);
^
ModbusSensor.cpp:205:42: note: candidate is:
In file included from /Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/Arduino.h:195:0,
from ModbusSensor.h:16,
from ModbusSensor.cpp:25:
/Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/HardwareSerial.h:29:18: note: virtual void HardwareSerial::begin(long unsigned int)
virtual void begin(unsigned long);
^
/Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/HardwareSerial.h:29:18: note: candidate expects 1 argument, 2 provided
ModbusSensor.cpp: In member function 'boolean modbusMaster::available()':
ModbusSensor.cpp:251: error: 'class HardwareSerial' has no member named 'availableForWrite'
if ((__hwSerial).availableForWrite() == SERIAL_TX_BUFFER_SIZE - 1) { //TX buffer empty
^
ModbusSensor.cpp:251: error: 'SERIAL_TX_BUFFER_SIZE' was not declared in this scope
if ((*_hwSerial).availableForWrite() == SERIAL_TX_BUFFER_SIZE - 1) { //TX buffer empty
^
no matching function for call to 'HardwareSerial::begin(uint16_t&, uint8_t&)'

Then I found this Thread in the Arduino Forum:
http://forum.arduino.cc/index.php?topic=142753.0

I changed "HardwareSerial" to "USARTClass" in Your ModbusSensor.cpp( one time ) and in ModbusSensor.h ( two times ).

But now I get this error:

Arduino: 1.6.5 (Mac OS X), Platine: "Arduino Due (Programming Port)"

ModbusSensor.cpp: In member function 'void modbusMaster::begin(uint16_t, uint8_t)':
ModbusSensor.cpp:205: error: call of overloaded 'begin(uint16_t&, uint8_t&)' is ambiguous
(__hwSerial).begin(baudrate, byteFormat);
^
ModbusSensor.cpp:205:42: note: candidates are:
In file included from /Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/variants/arduino_due_x/variant.h:39:0,
from /Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/Arduino.h:201,
from ModbusSensor.h:16,
from ModbusSensor.cpp:25:
/Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/USARTClass.h:111:10: note: void USARTClass::begin(uint32_t, USARTClass::USARTModes)
void begin(const uint32_t dwBaudRate, const USARTModes config);
^
/Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/USARTClass.h:111:10: note: no known conversion for argument 2 from 'uint8_t {aka unsigned char}' to 'USARTClass::USARTModes'
/Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/USARTClass.h:112:10: note: void USARTClass::begin(uint32_t, UARTClass::UARTModes)
void begin(const uint32_t dwBaudRate, const UARTModes config);
^
/Users/abe/Library/Arduino15/packages/arduino/hardware/sam/1.6.7/cores/arduino/USARTClass.h:112:10: note: no known conversion for argument 2 from 'uint8_t {aka unsigned char}' to 'UARTClass::UARTModes'
ModbusSensor.cpp: In member function 'boolean modbusMaster::available()':
ModbusSensor.cpp:251: error: 'SERIAL_TX_BUFFER_SIZE' was not declared in this scope
if ((__hwSerial).availableForWrite() == SERIAL_TX_BUFFER_SIZE - 1) { //TX buffer empty
^
call of overloaded 'begin(uint16_t&, uint8_t&)' is ambiguous

Will You please help me porting Your great work to an Arduino DUE?

@peninquen
Copy link
Owner

I'm sorry, at this moment I can't spend time in this project. Also I haven't studied Arduino DUE and different libraries to adapt.

This problem is developed in #11
you can use a different alternative to check when the Txbuffer is empty. Maybe UARTclass has a bool function to check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants