| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 9072 人关注过本帖
标题:gsm模块的代码问题
只看楼主 加入收藏
ffhhaa
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-3-14
收藏
 问题点数:0 回复次数:3 
gsm模块的代码问题
有人编写了下面的代码是关于gsm接口的模块,要我在里面编写sms发送,接受,初始化。。。。。的代码(此人暂时联系不上),可是我现在不知道怎么读下面的代码,不知道它们的意思是什么,比如说 这个宏定义 #define GSM_INTERFACE_MSGQ_MSG_CNT            20 ,#define GSM_INTERFACE_TIMER_STEP            500 要说明什么问题是什么意思,什么是多线程,什么是定时器。。。。。???是个初学的大家不要见笑,我只是实话实话,想读懂代码然后在编写代码。因为没什么开发的经验所以想问问大家如何快的入门真正的开发。先谢谢大家了
 *******************************************************************************/
#include "fsu.h"
#include "osvl.h"

#define GSM_INTERFACE_MSGQ_MSG_CNT            20
#define GSM_INTERFACE_MSGQ_MSG_MAX_LEN        40
#define GSM_INTERFACE_THREAD_PRIORITY        OSVL_THREAD_PRIORITY_BELOW_NORMAL
#define GSM_INTERFACE_THREAD_STACK_SIZE        8096
#define GSM_INTERFACE_TIMER_STEP            500
#define GSM_INTERFACE_TIMER_OPTION            OSVL_TIMER_FOREVER

OSVL_HANDLE g_hGSM_interfaceMsgQ     = OSVL_NULL;
OSVL_HANDLE g_hGSM_interfaceThread     = OSVL_NULL;
OSVL_INT     g_hGSM_interfaceTimer;

OSVL_DWORD fsu_GSM_interface_Thread(OSVL_DWORD dwParam)
{
    int bSuc = 0;
    char buf[200];
    int len;
    osvl_DateTime DateTime;
    
    while(1)
    {
        len = osvl_msg_Read(g_hGSM_interfaceMsgQ, (OSVL_CHAR *)buf, sizeof(buf), OSVL_INFINITE);
        if((len)&&(buf[0] == 'S'))
        {
            osvl_rtc_GetCurDateTime(&DateTime);
            osvl_trace("fsu_GSM_interface_Thread Rece At %04d-%02d-%02d %02d:%02d:%02d\r\n",
                DateTime.year,
                DateTime.month,
                DateTime.day,
                DateTime.hour,
                DateTime.min,
                DateTime.sec
                );
        }
    }

    return bSuc;
}

OSVL_VOID fsu_GSM_interface_Timer(OSVL_INT nTimerID, OSVL_DWORD dwParam, OSVL_DWORD dwOption)
{
    char buf[]="S";
//    osvl_msg_Write(g_hGSM_interfaceMsgQ, (OSVL_CHAR *)buf, sizeof(buf), 0, OSVL_MSG_NORMAL);
}


/*******************************************************************************
 * GSM接口初始化
 ******************************************************************************/
int GSM_interface_Init(void)
{
//    GSM_interface_config *pGSM_interface_Conf;
    int bSuc = 1;

    g_hGSM_interfaceMsgQ = osvl_msg_Create(GSM_INTERFACE_MSGQ_MSG_CNT, GSM_INTERFACE_MSGQ_MSG_MAX_LEN, 0);
    osvl_assert(g_hGSM_interfaceMsgQ);
    if (!g_hGSM_interfaceMsgQ)
    {
        osvl_set_errno(FSU_ER_GSM_INTERFACE_INIT_MSGQ);
        return 0;
    }
    
    g_hGSM_interfaceThread = osvl_thread_CreateThread(GSM_INTERFACE_THREAD_PRIORITY,
        fsu_GSM_interface_Thread, (OSVL_DWORD)g_hGSM_interfaceMsgQ, GSM_INTERFACE_THREAD_STACK_SIZE);
    osvl_assert(g_hGSM_interfaceThread);
    if (!g_hGSM_interfaceThread)
    {
        osvl_set_errno(FSU_ER_GSM_INTERFACE_INIT_THREAD);
        return bSuc;
    }

    g_hGSM_interfaceTimer = osvl_timer_CreateTimer(fsu_GSM_interface_Timer, 0);
    osvl_assert(g_hGSM_interfaceTimer);
    if (!g_hGSM_interfaceTimer)
    {
        osvl_set_errno(FSU_ER_GSM_INTERFACE_INIT_CREATE_TIMER);
        return 0;
    }
    
    bSuc = osvl_timer_SetTimer(g_hGSM_interfaceTimer, GSM_INTERFACE_TIMER_STEP, GSM_INTERFACE_TIMER_OPTION);
    osvl_assert(bSuc);
    if (!bSuc)
    {
        osvl_set_errno(FSU_ER_GSM_INTERFACE_INIT_SET_TIMER);
        return bSuc;
    }

    return bSuc;
}

/*******************************************************************************
 * GSM接口关闭
 ******************************************************************************/
int GSM_interface_DeInit(void)
{
    int bSuc = 1;

    bSuc = osvl_timer_DeleteTimer(g_hGSM_interfaceTimer);
    osvl_assert(bSuc);
    if (!bSuc)
    {
        osvl_set_errno(FSU_ER_GSM_INTERFACE_DEINIT_TIMER);
        return bSuc;
    }

    bSuc = osvl_thread_KillThread(g_hGSM_interfaceThread);
    osvl_assert(bSuc);
    if (!bSuc)
    {
        osvl_set_errno(FSU_ER_GSM_INTERFACE_DEINIT_THREAD);
        return bSuc;
    }

    bSuc = osvl_msg_Close(g_hGSM_interfaceMsgQ);
    osvl_assert(bSuc);
    if (!bSuc)
    {
        osvl_set_errno(FSU_ER_GSM_INTERFACE_DEINIT_THREAD);
        return bSuc;
    }

    return bSuc;
}

/*******************************************************************************
 * 读GSM接口数据
 ******************************************************************************/
unsigned int GSM_interface_GPRS_ReadNChars(int nChannel,
                                    unsigned char *buffer,
                                    unsigned int chars_to_read)
{
    unsigned int nNum = 0;

    return nNum;
}

/*******************************************************************************
 * 往GSM接口写数据
 ******************************************************************************/
unsigned int GSM_interface_GPRS_WriteNChars(int nChannel,
                                     unsigned char *buffer,
                                     unsigned int chars_to_write)
{
    unsigned int i;
    unsigned int nNum = chars_to_write;
    
    osvl_trace("GSM_interface_GPRS_WriteNChars Len=%d --", chars_to_write);
    for(i=0; i<chars_to_write; i++)
    {
        osvl_trace("-%02X", buffer[i]);
    }
    osvl_trace("\r\n");
    return nNum;
}


/*******************************************************************************
 * 读GSM接口数据
 ******************************************************************************/
unsigned int GSM_interface_SMS_ReadNChars(int nChannel,
                                    unsigned char *buffer,
                                    unsigned int chars_to_read)
{
    unsigned int nNum = 0;

    return nNum;
}

/*******************************************************************************
 * 往GSM接口写数据
 ******************************************************************************/
unsigned int GSM_interface_SMS_WriteNChars(int nChannel,
                                     unsigned char *buffer,
                                     unsigned int chars_to_write)
{
    unsigned int i;
    unsigned int nNum = chars_to_write;

    osvl_trace("GSM_interface_SMS_WriteNChars Len=%d --", chars_to_write);
    for(i=0; i<chars_to_write; i++)
    {
        osvl_trace("-%02X", buffer[i]);
    }
    osvl_trace("\r\n");

    return nNum;
}
搜索更多相关主题的帖子: gsm 模块 代码 
2008-10-27 16:36
永夜的极光
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2721
专家分:1
注 册:2007-10-9
收藏
得分:0 
文件不完整,那两个头文件的内容呢?

从BFS(Breadth First Study)到DFS(Depth First Study)
2008-10-27 18:59
ffhhaa
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-3-14
收藏
得分:0 
fsu是现场监控单元的意思,osvl是操作系统虚拟层

fsu.h


#ifndef _FSU_H_
#define _FSU_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "fsu_errno.h"
#include "fsu_setting.h"
#include "fsu_hw.h"
#include "fsu_alarm.h"
#include "fsu_a_interface.h"
#include "fsu_b_interface.h"
#include "fsu_gsm_interface.h"
#include "fsu_photo.h"
#include "fsu_init.h"
#include "fsu_main.h"

#ifdef __cplusplus
}
#endif

#endif //_FSU_H_



osvl.h

#ifndef _OSVL_H_
#define _OSVL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "osvl_def.h"
#include "osvl_errno.h"
#include "osvl_trace.h"            //1
#include "osvl_semaphore.h"        //2
#include "osvl_thread.h"        //3
#include "osvl_rtc.h"            //4
#include "osvl_uart.h"            //5
#include "osvl_msg.h"            //6
#include "osvl_timer.h"            //7
#include "osvl_gpio.h"            //8
#include "osvl_ffs.h"            //9
#ifdef OSVL_SUPPORT_SOCKET
    #include "osvl_socket.h"        //10
#endif

OSVL_BOOL osvl_init(OSVL_VOID);
OSVL_BOOL osvl_deinit(OSVL_VOID);

#ifdef WIN32
    #pragma comment(lib, "user32.lib")
    #pragma comment(lib, "Kernel32.lib")
    #pragma comment(lib, "winmm.lib")
    #pragma comment(lib, "ws2_32.lib")
#endif

#ifdef __cplusplus
}
#endif

#endif //_OSVL_H_
2008-10-28 08:43
高晓赫
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-4-16
收藏
得分:0 
您好,请问现在有完整的GSM模块代码吗
2017-04-17 15:58
快速回复:gsm模块的代码问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018773 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved