Compiling Serial1.readBytes

This small sketch will not compile. Am I reading the reference wrong?

int numbytes; 
byte InBytes[50] ;
char InChar[50];
void setup() 
{
	Serial.begin(115200);//  initialize both serial ports:
	Serial1.begin(115200);
}

void loop()
{
	if (Serial1.available() )
	{
		numbytes = Serial1.readBytes(InBytes,50);
		numbytes = Serial1.readBytes(InChar,50);
	}

}

The error message is:

Test2.ino: In function 'void loop()':
Test2:14: error: invalid conversion from 'byte*' to 'char*'
Test2:14: error: initializing argument 1 of 'size_t Stream::readBytes(char*, size_t)'

The reference for StreamReadBytes says:

readBytes()

Description
readBytes() read characters from a stream into a buffer. The function terminates if the determined length has been read, or it times out (see setTimeout()).
readBytes() returns the number of characters placed in the buffer. A 0 means no valid data was found.
This function is part of the Stream class, and is called by any class that inherits from it (Wire, Serial, etc). See the Stream class main page for more information.
Syntax
stream.readBytes(buffer, length)
Parameters
stream : an instance of a class that inherits from Stream.
buffer: the buffer to store the bytes in (char[] or byte[])
length : the number of bytes to read (int)
Returns
byte

Thanks...... Jim

Am I reading the reference wrong?

Yes, and no. The char and byte types are the same size, so they are sort of interchangeable. But, the method is defined as taking a char array. If you want to use a byte array, and I can't imagine why it matters, lie to the function:

Serial1.readBytes((char *)InBytes, 50);

That makes a huge difference in the output from my sketch. Thanks.
Are you saying that the reference is in error when it says:

buffer: the buffer to store the bytes in (char[] or byte[])

I suspect that when the documentation was written, there are plans to overload the readBytes() method to accept either a char array or a byte array. But, plans change and documentation doesn't always keep up.

That makes a huge difference in the output from my sketch.

How?

This is the sketch I am working with. It reads bytes from a GPS module over the Mega serial port Serial1.

int i = 1;
int numbytes;
byte InBytes[50];
char InChar[5];
void setup() {
	Serial.begin(115200);//  initialize both serial ports:
	Serial1.begin(115200);
	Serial.println("Init Complete");
	delay(1000);
}

void loop()
{
	{
		if (Serial1.available() )
		{
			//Serial1.readBytes((char *)InBytes,50);
			Serial1.readBytes( InChar,50);
			for (i = 0;i<50;i++)
			{
				//Serial.print(InBytes[i],HEX);
				Serial.print(InChar[i],HEX);
				Serial.print (" ");
			}  
		}
	}

	delay(1000);
}

This is the output:

Port open
Init Complete
FFFFFFB5 62 D 3 1C FFFFFFD1 3 FFFFFFCD 2B FFFFFFEA FFFFFFCB 6 FFFFFFC8 47 FFFFFFD8 FFFFFFB4 28 13 2C 40 4 0 FFFFFFD8 FFFFFFB4 28 13 18 2B 4 0 2A 0 0 0 2F 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0

When I change the two comments this is the output:

Port open
Init Complete
B5 62 D 3 1C 0 0 CD 2C 0 C8 6 C8 6 2E F 9A 13 65 0 5 0 2E F 9A 13 66 EB 4 0 2A 0 0 0 7E 8F 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Thats what I am sending from the GPS module.
Why its that way I have no clue...

				Serial.print(InChar[i],HEX);

Why? I do not know of a single GPS that sends binary data. Why do you want to print the characters received in HEX format?

Well I know of a GPS that sends binary. The ublox LEA 6 does when you turn on the UBX protocol.

The UBX protocol has data in it that is not available in the standard NMEA messages and I need it.

The char and byte types are the same size, so they are sort of interchangeable.

They do not have the same range, though. A byte has a range from 0 to 255. A char has a range from -128 to 127. If one type produces useful data, and the other does not, then it is not rocket science to figure out which type to use.

If that type causes issues with the readBytes() function, you can use a cast or not use the readBytes() function. After all, it is not doing anything that read() doesn't.

Your right of course but after years and years of programming Pascal and Delphi I am used to the idea that 'char' is short for character and therefore a signed character makes no sense at all (what would a negative letter 'A' be in the real world). So I prefer to use the byte type for the range 0..255 and its jarring to have to cast for it.
BTW - don't overstate rocket scientists. I used to be one... XD