[SOLVED] Serial pointer issues

I am working on a project that allows an Arduino to act as a USB DMX lighting interface. When I made my initial messy program, my code worked flawlessly. However, I want to make it into a library class so that others can make similar devices easily. Unfortunately, my code does not work.

My Arduino Mega does not respond to messages at all. My Teensy responds, but it responds to every message with the label==77 response. I am stumped.

My forum post was more than 9000 characters, so I had to include the files as attachments.

This is my first undertaking of an Arduino class this complex. I believe that the issue is somewhere in the serial pointer.


Simple_Test.ino (1.63 KB)

DMXUSB.cpp (6.43 KB)

DMXUSB.h (1.87 KB)

I figured out my issue! I needed to reset the state bit after getting to the final bit:

  if (b == 0xE7) { // if final bit
    state = STATE_START; // start over the sequence
    // ...do something with data

I believe that the issue is somewhere in the serial pointer.

So, test that hypothesis. Create a far simpler library that takes a pointer to a HardwareSerial instance, as this library does when running on a Mega.

Have that class do nothing more than receive serial data and convert upper case letters to lower case and convert lower case letters to upper case, and print the result back to the serial port. Open the serial monitor app and type some text. If you get back what you expect, it is not the use of the Serial instance that it the problem.

I solved the issue by placing Serial.write at several points in the code. I found that the byte-decoding loop was only firing once, so I realized that the state wasn't resetting.