Home > Mobile >  Android serial port development
Android serial port development

Time:09-30

Do a similar vending machines in the subway system, the machine has an android, now need to through the aisle android control machine, motor rotation, the machine over there gave the following interface document, the android related library android_serialport_api these serial communication has been configured, the class is encapsulated SerialPortUtil others, excuse me, in the document the last start motor, check code is how to set up, literally set?


CodePudding user response:

See you this description has nothing to do and check code should be literally write 2 bytes is ok

CodePudding user response:

Are you send CRC check code to the machine, the machine is returned CRC check code, don't have to manually, the CRC check code algorithm, baidu has a lot of

CodePudding user response:

Look at your document, check code should be CRC check code, is to keep data before using CRC algorithm calculated results,

This kind of problem as long as you find out what is CRC is good ah,
The rest of the chart, you direct that question to the hardware store is,
Business is too specific, it is difficult to get reply

CodePudding user response:

Both sides agree, good, is no check according to the instructions

CodePudding user response:

Check code, using the algorithm of CRC algorithm can search on to making CRC code keywords, to find the Java code to download

CodePudding user response:

CRC algorithm download link https://download.csdn.net/download/alphen/11853719

CodePudding user response:

such a simple thing, see how the document is the CRC16 calibration algorithm, CRC16 is two bytes, for example, his hand is not to know, please,
Don't listen to those irresponsible, write at random, the somebody else defines the agreement, defines the check code, is used in the process of communication, in order to avoid errors in the process of data transmission, just need,

CodePudding user response:

CRC16 is there are many kinds of, IBM, USB, MODBUS, DNP and so on,
Well, tell you you this algorithm of concrete is CRC16 MODBUS mode,


CodePudding user response:


Well, today is too idle, help you find the Java source code, several algorithm with validation under
https://www.cnblogs.com/lujiannt/p/9246256.html
https://www.cnblogs.com/koneloong/p/5218136.html
https://segmentfault.com/a/1190000019393677? Utm_source=tag - newest
https://github.com/jichengyue/ModbusCRC16



CodePudding user response:

Novice just contact android a serial port, now send data in the question, sent have no reaction, excuse me to send "0 x010xf00xf0" hexadecimal, how to transform,
Byte [] mBuffer=new byte [3].

The Arrays. The fill (mBuffer, (byte) 0 x01);
The Arrays. The fill (mBuffer, 0 xf0 (byte));
The Arrays. The fill (mBuffer, 0 xf0 (byte));

I'm such a turn, but send did not respond to the machine

CodePudding user response:

The
references to the tenth floor gd6321374 response:

Well, today is too idle, help you find the Java source code, several algorithm with validation under
https://www.cnblogs.com/lujiannt/p/9246256.html
https://www.cnblogs.com/koneloong/p/5218136.html
https://segmentfault.com/a/1190000019393677? Utm_source=tag - newest
https://github.com/jichengyue/ModbusCRC16






feels the last link is making the spectral point


11 references Christ_Day response:
novice just contact android a serial port, now send data in the question, sent have no reaction, excuse me to send "0 x010xf00xf0" hexadecimal, how to transform,
Byte [] mBuffer=new byte [3].

The Arrays. The fill (mBuffer, (byte) 0 x01);
The Arrays. The fill (mBuffer, 0 xf0 (byte));
The Arrays. The fill (mBuffer, 0 xf0 (byte));

I'm such a turn, but send the machine did not respond to




That simple,
/* * 
* strings to Hexadecimal array, seperate string by space
* @ param strHexValue Hexadecimal string
* @ return byte array
*/
Public static byte [] stringToByteArray (String strHexValue) {
String [] strAryHex=strHexValue. Split (" ");
Byte [] btAryHex=new byte [strAryHex length].

Try {
Int nIndex=0;
For (String strTemp: strAryHex) {
BtAryHex [nIndex]=(byte) Integer. ParseInt (strTemp, 16);
NIndex++;
}
} the catch (a NumberFormatException e) {

}

Return btAryHex;
}




CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related