C
C
Chvalov2015-08-27 00:06:54
Java
Chvalov, 2015-08-27 00:06:54

How to send commands to the controller from under Java?

There is a list of commands, but I don’t understand how to transfer them.
For example, there is a command to get the device status:
03h
I send it like this:
address, com, -, -, -, -, crc low, crc hi
1, 3, 0, 0, 0, 0, crc low, crc hi
crc low , crc hi is a checksum that is automatically calculated by the software. The
question is, how can I send the following commands as byte:
-05h
A0h
90h
A1h
?
I would like to see how to correctly send these commands using some examples written in java, and ideally under Android

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kumanin, 2015-08-27
@Chvalov

It is not clear what is not clear. )))

byte cmd[] = {0x01, 0x05, 0x00, 0x00, 0x00, 0x00, crc low, crc hi}
SomeStream s = ...
s.write(smd);

UPD:
For the byte to be unsigned
byte b = (byte)(0xFF & 0x90); // b == 144

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question