Author Topic: Usage of HardwareSerial class  (Read 1967 times)

0 Members and 1 Guest are viewing this topic.

SamMarco

Usage of HardwareSerial class
« on: August 22, 2012, 01:36:12 PM »
Hello all,

I'm modifying the Modbus Slave library written by jpmzometa and others at

http://sites.gogle.com/site/jpmzometa/

I would like to work on other processors than the AtMega328. Indeed I would like to port this to an AtMega1284. My purpose is to use other Serial ports (here there are Serial and Serial1) instead of Serial. In order to implement this, I've started to modify the Constructor and added new class Constructors which include the serial port number

Code: [Select]
Void Modbus::configure(unsigned char slave, long baud)
{
 Switch( serno ) {
  Case 1:
    Port = Serial1;
    Break;
  Case 2:
    Port = Serial2;
    Break;
  Case 3:
    Port = Serial3;
    Break;
  Default:
    Port = Serial;
    Break; }
}

Serno has been declared as a private attribute which belongs to ModbusSlave and port is a HardwareSerial object.

The code shown here fails. It needs to know the target processor to compile properly. How can I implement this?

Best Regards,


SAMUEL
« Last Edit: September 02, 2012, 02:51:33 PM by SamMarco »

bhagman

Re: Usage of HardwareSerial class
« Reply #1 on: August 29, 2012, 09:32:09 AM »
Can you post the errors you're getting?

SamMarco

Re: Usage of HardwareSerial class
« Reply #2 on: September 02, 2012, 12:52:00 PM »
Yes, here they are:

Code: [Select]
rtuMaster_tag.cpp: In member function 'void ModbusSlave::configure(unsigned char, long int, char)':
ModbusSlave:564: error: error: 'Serial1' was not declared in this scope
ModbusSlave:567: error: error: 'Serial2' was not declared in this scope
ModbusSlave:570: error: error: 'Serial3' was not declared in this scope
/home/samuel/Binaris/wiring-0100/cores/Common/FIFO.h: In member function 'FIFO<unsigned char, 32>& FIFO<unsigned char, 32>::operator=(const FIFO<unsigned char, 32>&)':
/home/samuel/Binaris/wiring-0100/cores/Common/FIFO.h:26: error: non-static const member 'const int FIFO<unsigned char, 32>::size', can't use default assignment operator
/home/samuel/Binaris/wiring-0100/cores/AVR8Bit/WHardwareSerial.h: In member function 'HardwareSerial& HardwareSerial::operator=(const HardwareSerial&)':
/home/samuel/Binaris/wiring-0100/cores/AVR8Bit/WHardwareSerial.h:101: note: synthesized method 'FIFO<unsigned char, 32>& FIFO<unsigned char, 32>::operator=(const FIFO<unsigned char, 32>&)' first required here
/home/samuel/Binaris/wiring-0100/cores/Common/FIFO.h: In member function 'FIFO<unsigned char, 16>& FIFO<unsigned char, 16>::operator=(const FIFO<unsigned char, 16>&)':
/home/samuel/Binaris/wiring-0100/cores/Common/FIFO.h:26: error: non-static const member 'const int FIFO<unsigned char, 16>::size', can't use default assignment operator
/home/samuel/Binaris/wiring-0100/cores/AVR8Bit/WHardwareSerial.h: In member function 'HardwareSerial& HardwareSerial::operator=(const HardwareSerial&)':
/home/samuel/Binaris/wiring-0100/cores/AVR8Bit/WHardwareSerial.h:101: note: synthesized method 'FIFO<unsigned char, 16>& FIFO<unsigned char, 16>::operator=(const FIFO<unsigned char, 16>&)' first required here
rtuMaster_tag.cpp: In member function 'void ModbusSlave::configure(unsigned char, long int, char)':
ModbusSlave:573: error: note: synthesized method 'HardwareSerial& HardwareSerial::operator=(const HardwareSerial&)' first required here
« Last Edit: September 02, 2012, 02:52:10 PM by SamMarco »