*a in serial.write would mean a pointer to the value at the address of the array, which is equivalent to the first element of an array? I think that makes sense.
Yes. Once it is dereferenced you don't know the context any more. So if you dereference it (to get 3, say) then you don't know that there is a 6 after it, because it is no longer the "address of 3" it is just 3.
void dostuff(uint8_t *a, int BUF)
{
Serial.write(a, BUF); // Serial.write wants the array pointer and the number of elements
}
As a style thing, I wouldn't call it BUF. All-caps identifiers tend to be used for constants (eg. 42). So it's just confusing to other programmers to do that.
In any case it's buffer-length, right? So a better name would be:
void dostuff(byte *buffer, int len)
As for the write - that writes a series of bytes, hence you see the funny characters. To see them individually you need to print them, eg.
void dostuff(byte *buffer, int len)
{
for (int i = 0; i < len; i++)
{
Serial.print(buffer [i], DEC); // print as decimal number
Serial.print (" "); // separating space
} // end of for
Serial.println (); // finish line off
}
Note that putting the array subscript in brackets dereferences into the i'th array entry.
I should be able to read the serial monitor or troubleshoot somehow.
One approach (apart from getting a logic analyzer which I personally find invaluable) is to use NewSoftSerial and communicate with your device on (say) pins 2 and 3, and then user hardware serial for debugging.