Hot answers tagged

5

Class Print is a base class of Arduino streaming. Stream is a derived class and adds reading capability. Print has only one abstract method write to write one byte to output or buffer. It is easy to implement a derived custom class. The classes derived from Stream are classes for hardware and software serial like HardwareSerial for Serial singletons and ...


1

You can't (and certainly shouldn't ever even try to) use SoftwareSerial on pins 0 and 1. Not when you're using Serial, since they are the same pins. Pick a different pair of pins for your GPS connection.


1

buffer[bufpos] = input & 127; bufpos++; Never use a buffer without a length protection. Flag if max buffer is reached, force to never write after last position. Like this: if ( bufpos > MaxBuff ) { Serial.print("errornumber"); bufpos = MaxBuff; //And force \n to finish errored message }


1

Please see some comments that can help you. Why do you use a software serial port? This ATmega has 4 real serial ports! delay() is dangerous in the main loop runtime. Try to use it only in setup. Every time you call a task, be sure you will not stay there forever. Get out of the task, if something seems to be too long time. Use millis() stamp time ...


1

I use a couple of techniques to measure code timing or to instrument it with mimimally disturbing time-critical code: Run the code-under-test in a loop of N times, taking the difference in the system clock before and after the loop. If the code-under-test is short enough that the loop housekeeping timing might significantly affect the measurement, I'll ...


Only top voted, non community-wiki answers of a minimum length are eligible