ssh远程快捷登录配置

目录

看看你本地有没有公钥

cat ~/.ssh/id_rsa.pub

ssh-keygen -t rsa
一直回车

ssh-copy-id -i ~/.ssh/id_rsa.pub username@39.108.131.169

vim ~/.ssh/config

Host geeku_lcy_169
   HostName 39.108.131.169
   Port 22
   User username


以后用 ssh geeku_lcy_169 就可以登录了,如果嫌长,你可以改成 Host 169 都行

22222222222222222222222222222222222
php mq 服务


sudo systemctl status mq

重启服务
sudo systemctl restart mq

停止服务
sudo systemctl stop mq

查看日志

sudo journalctl -u mq -f

设置开机启动
sudo systemctl enable mq

取消开机启动
sudo systemctl disable mq

服务配置文件位置
cat /etc/systemd/system/mq.service

memtest.sh
#!/bin/bash

while [ "1" ]; do
    fm=$(cat /proc/meminfo | grep "MemFree" | awk -F" " '{print $2}')
    curl "http://192.168.8.211/wms2/index.php/api/memfree" -d memfree=$fm

    sleep 1
done

//查找出入库order订单最早(时间戳最小)的
int search_dir(char *path, char* out[])//查找path目录及其子目录下后缀为.tmp的文件
{
	DIR *dir=NULL;
	struct dirent *entry=NULL;
	int i = 0;
	int min=0;
	if((dir=opendir(path))==NULL)//打开目录,返回该目录下的由目录和文件组成的列表
	{
		printf("opendir failed\n");
		return -1;
	}

	while((entry=readdir(dir))!=NULL)//循环读取列表中目录(子目录)或文件的信息
	{
		if(strcmp(entry->d_name,".")==0||strcmp(entry->d_name,"..")==0)//滤过本地目录及上级目录的信息,防止死循环
			continue;
		// if(4==entry->d_type)//子目录,递归继续遍历子目录
		// {
		// 	char pathbuf[1024]={0};
		// 	sprintf(pathbuf,"%s/%s",path,entry->d_name);
		// 	search_dir(pathbuf);
		// }
		// else//文件
		// {
			char *tmp=strrchr(entry->d_name,'.');
			if(tmp==NULL)
				continue;
			if(strcmp(tmp,".tmp")==0)
			{
				char buf[1024]={0};
				sprintf(buf,"%s/%s",path,entry->d_name);
				//同步order信息
				char *data_str = NULL;
				load_order_data(entry->d_name, &data_str);
				GeeKuDbgPrint("data_str:%s\n",data_str);

				// GeeKuDbgTrace();
				if(entry->d_name !=NULL){
					if(post_data(GEEKU_UPDATE_ORDER,data_str)==200)
					{
						if(remove(buf) == 0)
						{
							printf("\n\033[0;35;1msync successfully\033[0m\n");
						}
					}
					free(data_str);
					printf("%s\n",strtok(entry->d_name, "."));
					// printf("%s\n",buf);
					out[i]=strtok(entry->d_name, ".");
				}


				i++;
			}
		// }
		// GeeKuDbgTrace();

	}
	// GeeKuDbgTrace();
	// GeeKuDbgPrint("%d\n",sizeof(out));
	// for(i=0;i<sizeof(out)-1;i++)
	// {
	// 	min=out[i];
	// 	printf("%s\n",min);
	// }
	closedir(dir);

	return out;
}

Makefile

CC=gcc

LIB=-L/usr/lib -L/usr/local/lib -ljson-c -lcurl


OUT=tty
all: tty
tty: tty.c
	$(CC) -g -o $@ $< $(LIB) -g
clean:
	-rm *.o $(OUT)

scann.sh

#!/bin/bash

#set -xv
#atty=$(stty -F /dev/ttyUSB0 raw speed 9600)
while [ "1" ];do
aaa=$(timeout 1 cat /dev/ttyUSB0 | grep "GKV1" | awk -F"=" '{print $NF}' )
#echo $aaa

if [ "$aaa" != "" ];then
	./tty $aaa
	echo "==============================================================="
fi
done

tty.c 扫码

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <json-c/json.h>
#include <curl/curl.h>
// #include <asm/termios.h>

#define DEV_NAME  "/dev/ttyUSB0"

#define GeeKuDbgEvent(format, s...) printf("\033[0;31;1m[GeeKuDbgMsg]\033[0m\033[0;34;1m[%s][%s:%d]\033[0m \033[0;33;1m" format"\033[0m",__FILE__,__FUNCTION__,__LINE__, ## s)
#define GeeKuDbgPrint(format, s...) printf("\033[0;31;1m[GeeKuDbgMsg]\033[0m\033[0;34;1m[%s][%s:%d]\033[0m " format,__FILE__,__FUNCTION__,__LINE__, ## s)
#define GeeKuDbgTrace() printf("\033[0;31;1m[GeeKuDbgMsg]\033[0m\033[0;34;1m[%s][%s:%d]\033[0m \n" ,__FILE__,__FUNCTION__,__LINE__)
#define GeeKuDbgStep()  printf("\033[0;31;1m[GeeKuDbgMsg]\033[0m\033[0;35;1m[%s][%s:%d]\033[0m \n" ,__FILE__,__FUNCTION__,__LINE__); getchar()
#define GeeKuDbgAssert(x) assert(x)
#define GeeKuDbgTrace2() printf("\033[0;36;1m[GeeKuDbgMsg]\033[0m\033[0;34;1m[%s][%s:%d]\033[0m \n" ,__FILE__,__FUNCTION__,__LINE__)
#define GeeKuDbgDump(x,y)	printf("\033[0;31;1m[GeeKuDbgDmp]\033[0m\033[0;34;1m[%s][%s:%d]\033[0m \n" ,__FILE__,__FUNCTION__,__LINE__);geeku_hexdump(x,y);
#define FALSE -1
#define TRUE   0
void geeku_hexdump(char* ptr,int length){
	char *pdata = (char*)ptr;
	int i=0;
	if(length > 0){
		printf("    ");
		if(length > 16){
			for(i=0;i<16;i++){
				printf("\033[0;34;1m%02X \033[0m",i);
			}
		}else{
			for(i=0;i<length;i++){
				printf("\033[0;34;1m%02X \033[0m",i);
			}
		}
		printf("\n");
		printf("\033[0;33;1m000\033[0m ");
		for(i=0;i<length;i++){
			printf("%02X ",pdata[i] & 0xff);
			if((i+1)%16 == 0 || (i+1) == length){
				int j = 0;
				printf(" | ");
				if(length > 16){
					for(j=((i+1)-16);j<=i;j++){
						if(pdata[j] < 0x7F && pdata[j] >= 0x20){
							printf("%c",pdata[j]);
						}else{
							printf(".");
						}
					}
				}else{
					for(j=0;j<=i;j++){
						if(pdata[j] < 0x7F && pdata[j] >= 0x20){
							printf("%c",pdata[j]);
						}else{
							printf(".");
						}
					}
				}
				if((i+1) < length){
					printf("\n");
					printf("\033[0;33;1m%03X\033[0m ",i+1);
				}
			}
		}
		printf("\n\n");
	}
}

int hex_string2char_array(char* pOut, const char* pInput, const int nInLen);
int hex_string2char_array(char* pOut, const char* pInput, const int nInLen)
{
    int i=0;
    int tc;
    for (i = 0; i < nInLen/2 ; i++)
    {
        sscanf(pInput+i*2, "%02X", &tc);
        pOut[i] = tc;
    }
    pOut[i] = '\0';
    return i;
}

//16 to 10
int htoi(char a[]){
	int len,t,sum=0;
	int i =0;
	len=strlen(a);
	for(i=0;i<len;i++){
		if(a[i]>='0'&&a[i]<='9'||a[i]>='a'&&a[i]<='f'||a[i]>='A'&&a[i]<='F'){
			if(a[i]>='0'&&a[i]<='9')
				t=a[i]-'0';
			else if(a[i]>='a'&&a[i]<='f')
				t=a[i]-'a'+10;//十六进制a转化为十进制是10,以此类推到f
			else
				t=a[i]-'A'+10;
			sum=sum*16+t;
		}
		else{
			printf("请输入正确的十六进制数!\n");
			break;
		}
	}
	return sum;
}

/**
 * 2019-05-23 KeMingYou
 * CRC8
 */
unsigned char CalBCC(unsigned char *buf,unsigned short len)
{
	unsigned char crc = 0;
	unsigned short pLen = 0;

	for( pLen = 0; pLen < len; pLen++)
	{
		crc ^= buf[pLen];
	}
	//TRACE_S("CalBCC:%x\r\n",(u8)~crc);
	return (unsigned char)~crc;
}

int speed_arr[] = {B115200, B38400, B19200, B9600, B4800, B2400, B1200, B300};
int name_arr[] = {115200, 38400, 19200, 9600, 4800, 2400, 1200, 300};
void set_speed(int fd, int speed){
    unsigned int   i;
    int   status;
    struct termios   Opt;
    tcgetattr(fd, &Opt);
    for ( i= 0; i < sizeof(speed_arr) / sizeof(int); i++) {
        if (speed == name_arr[i]) {
            tcflush(fd, TCIOFLUSH);
            cfsetispeed(&Opt, speed_arr[i]);
            cfsetospeed(&Opt, speed_arr[i]);
            status = tcsetattr(fd, TCSANOW, &Opt);
            if (status != 0) {
                perror("tcsetattr fd1");
                return;
            }
            tcflush(fd,TCIOFLUSH);
        }
    }
}

/**
*@brief   设置串口数据位,停止位和效验位
*@param fd     类型 int 打开的串口文件句柄*
*@param databits 类型 int 数据位   取值 为 7 或者8*
*@param stopbits 类型 int 停止位   取值为 1 或者2*
*@param parity 类型 int 效验类型 取值为N,E,O,,S
*/
int set_Parity(int fd,int databits,int stopbits,int parity)
{
    struct termios options;
	if ( tcgetattr( fd,&options) != 0)
	{
	    perror("SetupSerial 1");
	    return(FALSE);
	}
	options.c_cflag &= ~CSIZE;
	switch (databits) /*设置数据位数*/
	{
	    case 7:
	        options.c_cflag |= CS7;
	        break;
	    case 8:
	        options.c_cflag |= CS8;
	        break;
	    default:
	        fprintf(stderr,"Unsupported data size\n");
        return (FALSE);
    }
	switch (parity)
	{
	    case 'n':
	    case 'N':
	//        options.c_cflag &= ~PARENB;   /* Clear parity enable */
	//        options.c_iflag &= ~INPCK;     /* Enable parity checking */
	        options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /*Input*/
	        options.c_oflag &= ~OPOST;   /*Output*/
	        break;
	    case 'o':
	    case 'O':
	        options.c_cflag |= (PARODD | PARENB); /* 设置为奇效验*/
	        options.c_iflag |= INPCK;             /* Disnable parity checking */
	        break;
	    case 'e':
	    case 'E':
	        options.c_cflag |= PARENB;     /* Enable parity */
	        options.c_cflag &= ~PARODD;   /* 转换为偶效验*/
	        options.c_iflag |= INPCK;       /* Disnable parity checking */
	        break;
	    case 'S':
	    case 's': /*as no parity*/
	        options.c_cflag &= ~PARENB;
	        options.c_cflag &= ~CSTOPB;
	        break;
	    default:
	        fprintf(stderr,"Unsupported parity\n");
        return (FALSE);
	}
	/* 设置停止位*/
	switch (stopbits)
    {
	    case 1:
	        options.c_cflag &= ~CSTOPB;
	        break;
	    case 2:
	        options.c_cflag |= CSTOPB;
	        break;
	    default:
	        fprintf(stderr,"Unsupported stop bits\n");
        return (FALSE);
    }
	/* Set input parity option */
	if ((parity != 'n')&&(parity != 'N'))
	        options.c_iflag |= INPCK;

	    options.c_cc[VTIME] = 5; // 0.5 seconds
	    options.c_cc[VMIN] = 1;

	    options.c_cflag &= ~HUPCL;
	    options.c_iflag &= ~INPCK;
	    options.c_iflag |= IGNBRK;
	    options.c_iflag &= ~ICRNL;
	    options.c_iflag &= ~IXON;
	    options.c_lflag &= ~IEXTEN;
	    options.c_lflag &= ~ECHOK;
	    options.c_lflag &= ~ECHOCTL;
	    options.c_lflag &= ~ECHOKE;
	    options.c_oflag &= ~ONLCR;

	tcflush(fd,TCIFLUSH); /* Update the options and do it NOW */
	if (tcsetattr(fd,TCSANOW,&options) != 0)
    {
        perror("SetupSerial 3");
        return (FALSE);
    }

	return (TRUE);
}


int do_set_usb()
{
	printf("我什么也不知道\n");
	return 0;
}

int do_set_speed(char *usb)
{
	int fd = 0;
	// int speed = 0;
	fd = open(usb, O_RDWR | O_NOCTTY);
    if(fd < 0) {
        perror(usb);
        return -1;
    }
    // printf("Input speed:");
    // scanf("%d",&speed);
    // getchar();
    set_speed(fd,9600);

   if (set_Parity(fd,8,1,'N')== FALSE)
    {
        printf("Set Parity Error\n");
        exit(1);
    }

}

int do_init_id(char *usb)
{
	int len = 0;
	int fd = 0;
	fd = open(usb, O_RDWR | O_NOCTTY);
    if(fd < 0) {
        perror(usb);
        return -1;
    }

	char buf[] = "A55515051601010100000001012C03000B5478787878787878787878";
    char szHex[64] = {0,};
	char rece[64] = {0,};

	int nLen = strnlen(buf,sizeof(buf));
	hex_string2char_array(szHex,buf,nLen);
    szHex[nLen/2] = CalBCC(szHex,nLen/2);

    while(1){

		len = write(fd, szHex, nLen+1);
		if (len < 0) {
			printf("write data error \n");
		}

		len = read(fd, rece, sizeof(rece));
	    // GeeKuDbgTrace();
        if (len < 0) {
            printf("read error \n");
            return -1;
        }

        if(rece !=NULL)
        {
        	// GeeKuDbgDump(rece,sizeof(rece));
        	// GeeKuDbgPrint("init ok!\n");
        	return 0;
        }

	}
}

int do_set_id(char *usb, char *t_id)
{
	do_init_id(usb);
	int len = 0;
	int fd = 0;
	fd = open(usb, O_RDWR | O_NOCTTY);
    if(fd < 0) {
        perror(usb);
        return -1;
    }
    // char buf[64] = {0,};
 //    char t_id[12] = {0,};
 //    printf("Input tid  number:");
 //    scanf("%s",t_id);
	// getchar();


	// sprintf(buf,"A55515051601010100000001012C03000B");
	// char buf[] = "A55515051601010100000001012C03000B5478787878787878787878";
	char buf[] = "A55515051601010100000001012C03000B";
	// GeeKuDbgPrint("%s\n",buf);
    char szHex[64] = {0,};
	char rece[64] = {0,};

	int nLen = strnlen(buf,sizeof(buf));
	// GeeKuDbgPrint("nLen:%d\n",nLen);
	hex_string2char_array(szHex,buf,nLen);
	// GeeKuDbgPrint("2:%d\n",nLen/2);
	memcpy(szHex+nLen/2, t_id, 11);
    szHex[nLen/2+11] = CalBCC(szHex,nLen/2+11);
    // GeeKuDbgDump(szHex,nLen/2+12);


	len = write(fd, szHex, nLen/2+12);
	if (len < 0) {
		printf("write data error \n");
	}

	len = read(fd, rece, sizeof(rece));
    // GeeKuDbgPrint("接收的数据:\n");
    if (len < 0) {
        printf("read error \n");
        return -1;
    }

    if(rece !=NULL)
    {
    	// GeeKuDbgDump(rece,sizeof(rece));
    	// GeeKuDbgPrint("%2x\n", rece[17]&0xff);
    	if (rece[17] == 0x55)
    	{
    		return 1;
    	}else{
    		return 0;
    	}

    }


	return 0;
}

char *do_read_id(char *usb)
{
	int len = 0;
	int len2 = 0;
	int fd = 0;
	char *str = NULL;
	fd = open(usb, O_RDWR | O_NOCTTY);
    if(fd < 0) {
        perror(usb);
        return NULL;
    }

	char buf[] = "A55515051601010100000001012C020000";
    char szHex[64] = {0,};
	char rece[64] = {0,};

	int nLen = strnlen(buf,sizeof(buf));
	hex_string2char_array(szHex,buf,nLen);
    szHex[nLen/2] = CalBCC(szHex,nLen/2);
	// GeeKuDbgDump(szHex,nLen/2+1);
	len = write(fd, szHex, nLen/2+1);
	if (len < 0) {
		printf("write data error \n");
	}

	len2 = read(fd, rece, sizeof(rece));
    // GeeKuDbgPrint("接收的数据:\n");
    if (len2 < 0) {
        printf("read error \n");
        return NULL;
    }

    // GeeKuDbgDump(rece,28);
    // GeeKuDbgPrint("%.*s\n", 11, &rece[17]);
    asprintf(&str,"%.*s", 11, &rece[17]);
    memset(rece,0,sizeof(rece));
    memset(szHex,0,sizeof(szHex));
    // GeeKuDbgTrace();


	return str;
}


char *do_read_mac(char *usb)
{
	char *mac = NULL;
	int len = 0;
	int len2 = 0;
	int fd = 0;
	fd = open(usb, O_RDWR | O_NOCTTY);
    if(fd < 0) {
        perror(usb);
        return NULL;
    }

	char buf[] = "A55515051601010100000001012C410000";
    char szHex[64] = {0,};
	char rece[64] = {0,};

	int nLen = strnlen(buf,sizeof(buf));
	hex_string2char_array(szHex,buf,nLen);
    szHex[nLen/2] = CalBCC(szHex,nLen/2);
	// GeeKuDbgDump(szHex,nLen/2);


	len = write(fd, szHex, nLen/2+1);
	if (len < 0) {
		printf("write data error \n");
	}

	len2 = read(fd, rece, sizeof(rece));
    // GeeKuDbgPrint("接收的数据:\n");
    if (len2 < 0) {
        printf("read error \n");
        return NULL;
    }

    // GeeKuDbgDump(rece,24);
    asprintf(&mac, "%02X%02X%02X%02X%02X%02X",rece[17]&0xff,rece[18] &0xff,rece[19] &0xff,rece[20] &0xff,rece[21] &0xff,rece[22] &0xff);
    memset(rece,0,sizeof(rece));
    memset(szHex,0,sizeof(szHex));
    // GeeKuDbgTrace();


	return mac;
}

char *usbscann(char *usb)
{
	int len = 0;
	int fd = 0;
	char *str = NULL;
	fd = open(usb, O_RDWR | O_NOCTTY);
    if(fd < 0) {
        perror(usb);
        return NULL;
    }

	char rece[21] = {0,};


    // while(1){

		len = read(fd, rece, 20);
		GeeKuDbgPrint("len:%d\n",len);
	    GeeKuDbgTrace();
        if (len < 0) {
            printf("read error \n");
            return NULL;
        }

        // GeeKuDbgDump(rece,sizeof(rece));

        asprintf(&str,"%s", &rece[0]);

        // GeeKuDbgPrint("%.*s\n", 20, &rece[0]);

        // GeeKuDbgTrace();
        // if(rece[sizeof(rece)+1]= '\0')
        // {
        // 	return NULL;
        // }
	// }
	return str;
}
//解析json格式数据
int print_json_str( char *json_msg )
{
	//json解析{"meta": {"code": 200,"message": "ok"},"body": []}}
	// {"ErrCode":1001,"ErrMsg":"主板类型无效,超出范围","Result":0}
	// GeeKuDbgPrint("json_msg:%s\n",json_msg);
	int code = 0;
	struct json_object *root = NULL;
	struct json_object *obj_code = NULL;

	root = json_tokener_parse(json_msg);
	obj_code = json_object_object_get(root, "ErrCode");
	code = json_object_get_int(obj_code);
	// GeeKuDbgPrint("%d\n", code);
	json_object_put(root);
	return code;
}

size_t write_data_func(void* buffer,size_t size,size_t nmemb,void *stream)
{
	char **ptr = stream;
	int i = 0;
	int offset = 0;
	char *tmp = NULL;

	*ptr = malloc((size * nmemb) + 1);
	memset(*ptr, 0, (size * nmemb) + 1);

	// GeeKuDbgPrint("size: %d, numb: %d\n", size, nmemb);
	for(i=0;i<size;i++){
		memcpy(&(*ptr)[offset], buffer, nmemb);
		offset += nmemb;
	}
	// GeeKuDbgPrint("fptr1: 0x%x\n", *ptr);

    return offset;
}

int post_data(char *url,char* data)
{
	CURL *curl;
  	CURLcode res;
  	char* fptr =NULL;
  	int ret_flag = -1;
	/* In windows, this will init the winsock stuff */
	curl_global_init(CURL_GLOBAL_ALL);

 	struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "Accept: application/json");
    headers = curl_slist_append(headers, "Content-Type: application/json");
    headers = curl_slist_append(headers, "charsets: utf-8");

	/* get a curl handle */
	curl = curl_easy_init();
	if(NULL == curl) {
		GeeKuDbgPrint("Init CURL failed...");
		return -1;
    }
	/* First set the URL that is about to receive our POST. This URL can
	   just as well be a https:// URL if that is what should receive the
	   data. */
	curl_easy_setopt(curl, CURLOPT_URL, url);
	/* Now specify the POST data */

	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
	//curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");
	curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write_data_func); //对返回的数据进行操作的函数地址
	curl_easy_setopt(curl,CURLOPT_WRITEDATA,&fptr); //这是write_data_func的第四个参数值
	curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

	curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 30L);
	/* Perform the request, res will get the return code */
	res = curl_easy_perform(curl);
	/* Check for errors */
	if(res != CURLE_OK){
		GeeKuDbgPrint("\033[0;31;1mcurl_easy_perform() failed: %s\033[0m\n",curl_easy_strerror(res));
		ret_flag = 400;
		GeeKuDbgTrace();
  		// fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
	}
    //正确响应后
    if( res == CURLE_OK )
    {
    	long res_code=-1;
	    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res_code);
    	if( res_code == 200 ){
        	ret_flag=print_json_str(fptr);
      	}
    }
    if(fptr != NULL ){
    	// GeeKuDbgPrint("fptr: 0x%x\n", fptr);
    	free(fptr);
    	fptr = NULL;
    }
	/* always cleanup */
	curl_easy_cleanup(curl);
	curl_slist_free_all(headers);
	curl_global_cleanup();

	return ret_flag;
}
int main(int argc, char const *argv[])
{
	int cmd = 0;
	char *usb ="/dev/ttyUSB1";
	int code =-1;
	char *did = NULL;
	char *mac = NULL;
	char *data = NULL;
	char boardType[2] = {0,};
	// char *aa = NULL;
	// char *usb1 ="/dev/ttyUSB1";

	do_set_speed(usb);
	// do_set_speed(usb1);
	// aa = usbscann(usb1);

	// GeeKuDbgPrint("aa:%s\n",aa);
	if(do_set_id(usb,argv[1])==1){

		did = do_read_id(usb);
		GeeKuDbgPrint("did:%s\n",did);


		strncpy(boardType, did+1, 1);
		boardType[2] = '\0';
		GeeKuDbgPrint("boardType:%s\n",boardType);
		mac = do_read_mac(usb);
		GeeKuDbgPrint("mac:%s\n",mac);
		// GeeKuDbgTrace();

		// usbscann(usb1);
		// char data[] = "{\"deviceid\":\"T123123123\"}";

		asprintf(&data,"{\"BoardType\":%s,\"ComType\":3,\"ChipType\":\"1.0\",\"DeviceNoIdList\":[%s],\"MacAddress\":\"%s\"}",boardType,did,mac);

		// GeeKuDbgPrint("data:%s\n",data);

		// code = post_data("http://wms.com/api/testpost",data);
		code = post_data("https://cps.geekuiot.com/service/device/DeviceNoInStock",data);

		// GeeKuDbgPrint("code:%d\n",code);
		if (code == 0)
		{
			GeeKuDbgPrint("设备ID:%s post 成功!\n",did);
		}else{
			GeeKuDbgPrint("设备ID:%s post 失败!\n",did);
		}
	}else{
		GeeKuDbgPrint("初始化设备失败!\n");
	}


	if (data != NULL)
	{
		free(data);
		data = NULL;
	}



	// while(1)
	// {
	// 	printf("***********************************************************************\n");
	// 	printf("1:Set ttyUSB \n2:Set ID\n3:Read ID \n4:Read MAC \n5: quit.\n");
	// 	printf("***********************************************************************\n");

	// 	printf("please choose: ");
	// 	scanf("%d",&cmd);
	// 	getchar();

	// 	switch(cmd)
	// 	{
	// 		case 1:
	// 		    do_set_usb();
	// 		    break;
	// 		case 2:
 //                do_set_id(usb);
	// 			break;
	// 		case 3:
	// 		    do_read_id(usb);
	// 			break;
	// 		case 4:
	// 		    do_read_mac(usb);
	// 		    break;
	// 		case 5:
	// 		    exit(0);
	// 		default:
	// 		    printf("error cmd.\n");

	// 	}

	// }
	return 0;
}


// https://cps-dev.geekuiot.com/device/DeviceNoInStock
// curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'https://cps-dev.geekuiot.com/device/DeviceNoInStock'
 反向 ssh
   主板:开ssh 命令:
   ssh -f -N -R 10000:localhost:22 liaochaoyong@192.168.8.17
   主机访问:
      ssh kemingyou@localhost -p 10000
      退出 exit
   主机拷贝文件:
   scp -P 10000 libgkdb.so root@localhost:/tmp

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦