使用Conexant USB CX93010调制解调器从串行端口获取Callerid?

问题描述 投票:-2回答:3

我有一个C#代码,但是当我将线路连接到手机时,它不需要从拨号调制解调器连接到USB端口的CallerID。它获得了CallerID,但是在程序运行和阅读线上我只有RING。

这是我的代码:

public partial class Form1 : XtraForm
{
    public Form1()
    {
        InitializeComponent();            
    }

    SerialPort sp ;
    private void simpleButton1_Click(object sender, EventArgs e)
    {            
        sp = new SerialPort(textEdit1.Text);
        sp.NewLine = "\r\n";
        sp.Parity = Parity.None;
        sp.DataBits = 8;
        sp.StopBits = StopBits.One;
        sp.DtrEnable = true;
        sp.WriteBufferSize = 1024;

        sp.Open();
        sp.WriteLine("AT+VCID=1");
        sp.RtsEnable = true;
        timer1.Start();
    }

    void sp_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {

    }

    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
        sp.Close();
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        memoEdit1.Text += "\n" + sp.ReadExisting();
    }

    private void simpleButton2_Click(object sender, EventArgs e)
    {
        sp.Close();
    }
c# serial-port modem
3个回答
1
投票

当您的调制解调器支持来电显示时,请使用AT + CLIP = 1。这将导致在调用调制解调器时显示未经请求的+ CLIP消息。

+ CLIP未经请求的消息通常表述如下:

+CLIP: <number>,<type>,,,,<cli validity>

其中<number>是一个字符串,其中包含由<type>定义的格式的数字。地址八位位组的<type>,例如国际号码为145. <cli validity>确定该号码是否被扣留等。


0
投票

科胜讯USB CX93010 ACF调制解调器没有FSK协议


0
投票

我根据我在Conexant USB CX93010上进行的一些测试发布了下面的代码。下面的代码是C(而不是C#),并在Linux(而不是Windows)上运行。但它应该为C#程序提供良好的基线。

该代码基于Sawdust编写的另一个Stack Overflow answer,它具有该程序的测试结果。

您还可以在http://www.arcelect.com找到Conexant调制解调器的全面AT命令集。它的日期是2001年,但它有更多的调制解调器的AT命令,而不是我在网上其他地方找到的。


这是代码。

#include <errno.h>
#include <fcntl.h> 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>

#define DISPLAY_STRING 1

int set_interface_attribs(int fd, int speed)
{
    struct termios tty;

    if (tcgetattr(fd, &tty) < 0) {
        printf("Error from tcgetattr: %s\n", strerror(errno));
        return -1;
    }

    cfmakeraw (&tty);
    cfsetospeed(&tty, (speed_t)speed);
    cfsetispeed(&tty, (speed_t)speed);

    if (tcsetattr(fd, TCSANOW, &tty) != 0) {
        printf("Error from tcsetattr: %s\n", strerror(errno));
        return -1;
    }
    return 0;
}

void write_command(int fd, const void* cmd, size_t len)
{
    if (len == ~(size_t)0)
        len = strlen((const char*)cmd);

    printf("Send %d: %s\n", (int)len, (const char*)cmd);

    int wlen = write(fd, cmd, len);

    if (wlen != len) {
        printf("Error from write: %d, %d\n", wlen, errno);
    }
    tcdrain(fd);    /* delay for output */
}

void read_response(int fd)
{
    char buf[256];
    int rlen = read(fd, buf, sizeof(buf) - 1);

    if (rlen > 0) {
#ifdef DISPLAY_STRING
        buf[rlen] = 0;
        printf("Read %d: \"%s\"\n", rlen, buf);
#else /* display hex */
        unsigned char *p;
        printf("Read %d:", rlen);
        for (p = buf; rlen-- > 0; p++)
            printf(" 0x%x", *p);
        printf("\n");
#endif
    } else if (rlen < 0) {
        printf("Error from read: %d: %s\n", rlen, strerror(errno));
    } else {  /* rlen == 0 */
        printf("Timeout from read\n");
    }
}

int main(int argc, char* argv[])
{
    int fd;
    const char portname[] = "/dev/ttyACM0";

    fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC);
    if (fd < 0) {
        printf("Error opening %s: %s\n", portname, strerror(errno));
        return -1;
    }

    /*baudrate 115200, 8 bits, no parity, 1 stop bit */
    set_interface_attribs(fd, B115200);

    write_command(fd, "ATZ\r", 4); /* Reset */

    read_response(fd);

    write_command(fd, "ATE0\r", -1);  /* Echo off */

    read_response(fd);

    write_command(fd, "AT+VCID=?\r", -1);  /* Query CallerID caps */

    read_response(fd);

    write_command(fd, "AT+CLIP=?\r", -1);  /* Query CallerID caps */

    read_response(fd);

    write_command(fd, "AT+VCID=1\r", -1);  /* Set CallerID */

    read_response(fd);

    printf("Entering loop, CTRL+C to break...\n\n");

    while (1)
    {
        read_response(fd);
    }

    return 0;
}

以下是使用手机的测试结果。我改了名字和电话号码;另外,它是程序的确切输出。

$ sudo ./modem.exe
Send 4: ATZ
Read 6: "
OK
"
Send 5: ATE0
Read 11: "ATE0
OK
"
Send 10: AT+VCID=?
Read 15: "
(0-2)

OK
"
Send 10: AT+CLIP=?
Read 9: "
ERROR
"
Send 10: AT+VCID=1
Read 6: "
OK
"

Entering loop, CTRL+C to break...

Read 8: "
RING
"
Read 67: "
DATE = 0214
TIME = 2116
NMBR = 2025551212
NAME = JANE DOE
"
Read 8: "
RING
"
Read 67: "
DATE = 0214
TIME = 2116
NMBR = 2025551212
NAME = JANE DOE
"
Read 8: "
RING
"
Read 8: "
RING
"
Read 8: "
RING
"

此外,你可以发送一个AT+GSR来获得真正的调制解调器版本,而不是Windows提供的(这看起来有点不准确):

Send 7: AT+GMR
Read 44: "AT+GMR
+GMR: CX93001-EIS_V0.2013-V92

OK"
© www.soinside.com 2019 - 2024. All rights reserved.