MTK7628外接MZ391 4G module模组,下发特殊AT命令的源代码

libra@SVN:~/openwrt_mtk_4G/MZ391_4G$ ls
make.sh  mz391_4g  mz391_4g.c
libra@SVN:~/openwrt_mtk_4G/MZ391_4G$ cat  mz391_4g.c 
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <signal.h>
#include <sys/statfs.h>
#include <mntent.h>
#include <sys/time.h>
#include <sched.h>
#include <errno.h>
#include    <sys/stat.h>
#include     <termios.h>
#include     <time.h> 
#include     <syslog.h>
#include     <stdarg.h>

int write_log(char *p)
{
        FILE *fp;

        if((fp=fopen("/tmp/mz391.conf","a"))==NULL)
        {
                printf("open /tmp/mz391.conf.conf file Fail,close!");
                return -1;
        }
        fputs(p,fp);
        fclose(fp);
        return 0;
}

static int zw_system(char *command)
{
        FILE *fp=NULL;
        char result_buf[128]={0};

        fp = popen(command, "r");
        if (NULL == fp)
        {
                printf("popen ERR\n");
                return -1;
        } 
        while(fgets(result_buf, sizeof(result_buf), fp) != NULL)
        {       
        }
        pclose(fp);
        return 0;       
}

int get_mz391_info()
{
        FILE *fp=NULL;
        char result_buf[128]={0};
        int info=-1;
        fp = popen("/usr/bin/lsusb", "r");
        if (NULL == fp)
        {
                printf("popen /usr/bin/lsusb ERR\n");
                return -1;
        } 
        while(fgets(result_buf, sizeof(result_buf), fp) != NULL)
        {       
                if (strstr(result_buf,"19d2:0581") || strstr(result_buf,"19d2:1557&#

  • 13
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值