Elatec GmbH TWN3A1 사용자 설명서
Elatec GmbH
Page 35 of 44
void HostSendHex(byte &Data, byte BitCnt, byte Width)
Convert a number, which is given as a bit field into hexadecimal ASCII format, and send it to the host.
Letters are sent in upper case.
Letters are sent in upper case.
Parameters:
byte &Data
A reference to an array of bytes, which contains the bit field
byte BitCnt
The number of bits, which are valid within the array of bytes. A
maximum of 128 bits can be converted.
maximum of 128 bits can be converted.
byte Width
Specifies the number of digits, the output should contain. If width is 0,
then at least 1 digit is sent. If Width is greater than the actual width of
the number to be converted, then the number is preceded by zeros.
then at least 1 digit is sent. If Width is greater than the actual width of
the number to be converted, then the number is preceded by zeros.
Return:
None.
Example:
byte ID[2];
ID[0] = 0x12;
ID[1] = 0x34;
HostSendHex(ID,16,0); // Result is 1234
HostSendHex(ID,8,5); // Result is 00012
HostSendHex(ID,13,5); // Result is 00246
ID[0] = 0x12;
ID[1] = 0x34;
HostSendHex(ID,16,0); // Result is 1234
HostSendHex(ID,8,5); // Result is 00012
HostSendHex(ID,13,5); // Result is 00246
void HostSendDec(byte &Data, byte BitCnt, byte Width)
Convert a number, which is given as a bit field into decimal ASCII format, and send it to the host.
Parameters:
byte &Data
A reference to an array of bytes, which contains the bit field
byte BitCnt
The number of bits, which are valid within the array of bytes. A
maximum of 128 bits can be converted.
maximum of 128 bits can be converted.
byte Width
Specifies the number of digits, the output should contain. If width is 0,
then at least 1 digit is sent. If Width is greater than the actual width of
the number to be converted, then the number is preceded by zeros.
then at least 1 digit is sent. If Width is greater than the actual width of
the number to be converted, then the number is preceded by zeros.
Return:
None.
Example:
byte ID[2];
ID[0] = 0x12;
ID[1] = 0x34;
HostSendDec(ID,16,0); // Result is 4660
HostSendDec(ID,8,5); // Result is 00018
HostSendDec(ID,13,5); // Result is 00582
ID[0] = 0x12;
ID[1] = 0x34;
HostSendDec(ID,16,0); // Result is 4660
HostSendDec(ID,8,5); // Result is 00018
HostSendDec(ID,13,5); // Result is 00582