Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error #41

Closed
jpacora opened this issue Jan 13, 2015 · 1 comment
Closed

Error #41

jpacora opened this issue Jan 13, 2015 · 1 comment

Comments

@jpacora
Copy link

jpacora commented Jan 13, 2015

Hello, im having this error:
RangeError: Illegal range: 0 <= 21 <= 16 <= 32

My code is:
var cmd = 'DYD,000000#';
var command = new ByteBuffer();
command.writeByte(0x78);
command.writeByte(0x78); // size
command.writeByte(5 + cmd.length); // size
command.writeByte(0x80); //Protocol Number
command.writeByte(4 + cmd.length); //Length of Command
command.writeByte(0x91); // Server Flag Bit end
command.writeUTF8String(cmd)
command.writeShort(crc.crc16ccitt(command.slice(2, 4)));
command.writeByte(0x0D); command.writeByte(0x0A); // ending
console.dir(command)
socket.write(command.toString('hex'))

@dcodeIO
Copy link
Member

dcodeIO commented Jun 2, 2015

Looks like you are missing a call to ByteBuffer#flip() after all relative write operations are complete.

@dcodeIO dcodeIO closed this as completed Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants