Hi i have a sketch working on a arduino Mega, it uses a rewritten hardwareserial library.
Now i want to upload it on my UNO, and yes i have rewritten the code because only one serial is available on the UNO. So i'm reading Serial data and sending it to softwareserial which i sniff with a USB/TTl adapter and Putty.
I think there are some alternations made in the hardwareserial that are not compatible with my UNO, i think it has to anything with different kinds of (registers/UCSR0A/UDR0 stuff)
Is there someone who knows how this works and who can check the alternated hardwareserial library for me.
I realy like to get it working on my UNO instead of Mega
can you please give me a hint, i'm bussy for three days for getting it to work.
I like the UNO to get some RX data from a EMS bus, the UNO has to decode it and send it through softserial to serail adapter so i can see the data.
Is it possible at the same time, or can't i use the 1 and only hardwareserial for this purpose???
Maybe something wrong with addressing or registers or baudrate????
Why an UNO? Why can't you keep using the solution that already works?
If you need something smaller than a Mega, consider the Micro. It has hardware serial independent of the USB serial, so you can decode serial data and send it to the PC without any messing around with other hardware or softwareserial. If you need true serial-to-serial, then a Teensy is even smaller and has good hardware serial for 3 ports, plus USB serial too.
In what way have you changed the Serial code, and in what way does it not work?
I'm pretty sure that the ATmega2560 and ATmega328 UARTs are essentially identical...
yes i have rewritten the code because only one serial is available on the UNO. So i'm reading Serial data and sending it to softwareserial
If I try to compile your code, I get that nefitSerial1 is undefined. I don't SEE anything in there that make nefitSerial1 be a SoftwareSerial port if the hardware doesn't exist; is this supposed to be the changed code, or the original Mega code?
The hardwareserial is changed to detect the end/stop/break of the message , a 11bit Null.
And for the record I found the parts/sketches on the Internet and was planning of using it only for decoding the bus message. The rest I edit to fit my needs. Only the part thats edited in the hardwareserial I can't seem to understand fully understand.
And I was using a uno cause I have another uno with wifi from arduino.org so I want to use that one to upload my data to my domoticz server. So I'm looking for an arduino with multiple UARTS and wifi.
This ombouwsoftserial.ino is the one using softwareserial and is not working.
I mad an other one using Ciao.write for wifi output and is also not working (ombouwuno9600.ino)
inline void store_char(unsigned char c, bool fe, NefitSerial *s)
{
int i = (unsigned int)(s->_rx_buffer_head + 1) % SERIAL_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != s->_rx_buffer_tail) {
s->_rx_buffer[s->_rx_buffer_head] = c;
s->_error_flag[s->_rx_buffer_head] = fe;
s->_rx_buffer_head = i;
}
}
The hardware serial you found on the net was NOT written to run on an Arduino. Look at the comments at the start of the cpp (modification history).
/*
NefitSerial.cpp - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 23 November 2006 by David A. Mellis
Modified 28 September 2010 by Mark Sproul
Modified 14 August 2012 by Alarus
*/
First version 06 ! Any one know when the first Ardunio was?
I assume that both hardware serials stem from the one provided by ATMEL
Then look at the way the #ifdef's are done. For example
/*
* on ATmega8, the uart and its bits are not numbered, so there is no "TXC0"
* definition.
*/
#if !defined(TXC0)
#if defined(TXC)
#define TXC0 TXC
#elif defined(TXC1)
// Some devices have uart1 but no uart0
#define TXC0 TXC1
#else
#error TXC0 not definable in NefitSerial.h
#e
I'd say the code was written for the ATmega8 and then modified to let it work with the Arduino mega.
I suspect that all the hardware dependent bits of the code are being lost in the c pre-processor. Which is why it compiles.
Which brings us back to - datasheets! Do you have the one for this thingy you are trying to talk to?
Find it and then look at the list of options provided by the Arduino H/W serial Look at the begin method.