Initial
This commit is contained in:
48
test/main.cpp
Normal file
48
test/main.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define T1_ADDRESS "28ffbb19841704c3"
|
||||
#define T2_ADDRESS "28ff112ca01705d0"
|
||||
#define T3_ADDRESS "28ffde61a01705e0"
|
||||
#define T4_ADDRESS "28ff3c09a017046b"
|
||||
#define T5_ADDRESS "28ff4459a01704e0"
|
||||
#define T6_ADDRESS "28ffbb19841704c3"
|
||||
#define T7_ADDRESS "28ff3e69a0170478"
|
||||
#define T8_ADDRESS "28ffcb4ba0170525"
|
||||
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef uint8_t DeviceAddress[8];
|
||||
|
||||
|
||||
int main() {
|
||||
char str_address[20];
|
||||
char* p_str = str_address;
|
||||
DeviceAddress out;
|
||||
uint8_t* p_out = out;
|
||||
char buff[3];
|
||||
|
||||
strcpy(str_address, T2_ADDRESS);
|
||||
memset(buff, 0, sizeof(buff));
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
buff[0] = *p_str++;
|
||||
buff[1] = *p_str++;
|
||||
*p_out++ = (uint8_t)strtol(buff, NULL, 16);
|
||||
|
||||
}
|
||||
|
||||
printf("%s\n", str_address);
|
||||
|
||||
for(int i = 0; i < sizeof(out); i++) {
|
||||
printf("%X ", out[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
10
test/makefile
Normal file
10
test/makefile
Normal file
@ -0,0 +1,10 @@
|
||||
OOUTDIR = o/
|
||||
|
||||
output: main.o
|
||||
g++ -std=c++0x -Wall $(OOUTDIR)main.o -o a.out
|
||||
|
||||
main.o: main.cpp
|
||||
g++ -c main.cpp -o $(OOUTDIR)main.o
|
||||
|
||||
clean:
|
||||
rm $(OOUTDIR)*.o a.out
|
||||
Reference in New Issue
Block a user