Giter Site home page Giter Site logo

gsmmodem's Introduction

GSMMODEM类库,帮助发送与接收短信(通过与短信猫进行串口通信)

gsmmodem's People

Contributors

engin0 avatar

gsmmodem's Issues

两个建议

Hi 

1)可以考虑增加一个读取各种短信的方法(不只是读取未读�
��短信),只需要增加一个类别参数(0:未读短信;1:已读�
��信;2:待发短信;3:已发短信;4:全部短信)
2)DecodedMessage 
中增加存储位置属性,这对于读取并删除短信很有用

呵呵,主要在实际应用中碰到了这种情况,我自己临时加了��
�样的方法,望在下一版中也能有这样的功能:)

Thanks & BR,
Peter

Original issue reported on code.google.com by [email protected] on 7 Sep 2011 at 4:47

svn

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 20 Feb 2012 at 4:39

svn 代码库中代码有遗漏

What steps will reproduce the problem?
1. 
编译GSMMODEMTest项目时,发现src\GSMMODEM\Properties\下没有AssemblyInfo.
cs
2. 编译Sample项目时,发现Samples\Sample\下没有App.config

第一个文件无所谓
第二个文件...请问到底里边有什么啊

不知道是否还有其他遗漏的文件
issus 
14也是我提交的,但是我多按了个回车,于是就自动提交了.请删
之

Original issue reported on code.google.com by [email protected] on 20 Feb 2012 at 4:42

1.0版bug

中文长短信发送时,短信发送出去,但是,报短信发送失败��
�异常;
原因是PDU 
USC2编码的函数长短信时,运行到了非长短信的那儿,多编码�
��一个错误的PDU串;
修复办法,更改PduEcoding.cs里面的private List<CodedMessage> 
PDUUSC2Encoder(string phone, string Text)函数,具体见:

Original issue reported on code.google.com by [email protected] on 2 Aug 2011 at 12:32

Attachments:

多条短信发送时,pe.UserData只能获取最后一次的内容,循环体中前几次的UserData获取不到

PDUEncoding pe = new PDUEncoding();
            pe.ServiceCenterAddress = "8613800311500";
            string tmp = string.Empty;
foreach (CodedMessage cm in pe.PDUEncoder(phone, msg))
{
   string a=cm.PduCode;
   string b=pe.UserData;//多条短信发送时,pe.UserData只能获取最后一次的内容,循环体中前几次的UserData获取不到
}

Original issue reported on code.google.com by [email protected] on 17 Sep 2011 at 2:15

使用WaveCom 8口短信猫池时,读Com口信息超时(1.0.0.19)

使用WAVECOM短信猫时,可以检测到串口,所有指令发送后,读�
��内容时超时,连接短信猫池时,可以检测到猫池,端口已占
用。

--------------------------------------------------
以下是连接时加上读机器码时的异常信息:

2011-6-21 14:39:18:Connect Modem(gmInfo): Exception:System.TimeoutException: 
操作已超时。
   在 GSMMODEM.GsmModem.SendAT(String ATCom) 位置 C:\Documents and Settings\Administrator\桌面\GSMMODEM2\src\GSMMODEM\GsmModem.cs:行号 338
   在 GSMMODEM.GsmModem.GetMachineNo() 位置 C:\Documents and Settings\Administrator\桌面\GSMMODEM2\src\GSMMODEM\GsmModem.cs:行号 249
   在 短信猫.Form1.button1_Click(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\桌面\GSMMODEM2\Samples\Sample\Form1.cs:行号 105

-------------------------------------------------------
以下是修改后的测试代码:
            if (gm.IsOpen == false)
            {
                try
                {
                    gm.Open();
                    label3.Text = "连接成功";
                    label3.ForeColor = Color.Green;

                }
                catch (Exception ee)
                {
                    LogInfo("Connect Modem: Exception:" + ee.ToString());
                    label3.Text = "连接失败";
                    label3.ForeColor = Color.Red;
                }

                try {
                    string gmInfo = gm.GetMachineNo();
                    LogInfo(" Connect Modem:" + gmInfo);
                }
                catch (Exception ee)
                {
                    LogInfo("Connect Modem(gmInfo): Exception:" + ee.ToString());

                }

Original issue reported on code.google.com by [email protected] on 21 Jun 2011 at 6:44

PDU识别短信的BUG(乱码情况)

有时3G的手机发过来的短信的DCS编码是19,这时实际上是UCS2编
码,但现在的代码无法识别,因为只认为编码=08的才是UCS2,�
��以乱码了。

修改以下的代码就OK啦。

//if (dataCodingScheme.Substring(1, 1) == "8")             //USC2编码
if (dataCodingScheme.Substring(1, 1) == "8" || dataCodingScheme.Substring(1, 1) 
== "9")  

这个地方困扰我一天了,嘿嘿,终于解决了。

请PM老兄考虑下个版本修改这个问题哦。

Original issue reported on code.google.com by [email protected] on 1 Oct 2011 at 1:45

对应的测试程序在发送短信时异常退出


1. 
示范程序发送短信到指定号码时,程序没有任何提示,自动��
�出,但目标手机号码能收到短信,不知道怎么回事呢,可能�
��什么原因呢,我看代码里也有用Try。



Original issue reported on code.google.com by [email protected] on 5 Sep 2013 at 5:33

PDUEncoding.cs中ServiceCenterAddress属性中len不应该减2吧

PDUEncoding.cs中ServiceCenterAddress属性get中
 get
            {
                int len = 2 * Convert.ToInt32(serviceCenterAddress.Substring(0, 2), 16);
                string result = serviceCenterAddress.Substring(4, len - 2);//len不应该-2吧,len本身就是通过前两位计算的短信中心长度(没把前两位列入len计算范围,所以没必要-2吧)

                result = ParityChange(result);
                result = result.TrimEnd('F', 'f');
                return result;
            }

Original issue reported on code.google.com by [email protected] on 20 Sep 2011 at 7:13

PDUEncoding->UserData编码和解码方式不一致

get使用的是直接通过char转换,
set使用的是BigEndianUnicode
虽然对于UNICODE码没有问题,但对于不在UNICODE编码范围的字符
(D800-DFFF),结果会不一致。
测试代码如下:
            int high = 0;
            string s1;
            StringBuilder sb = new StringBuilder();
            for (; high < 0x100; high ++)
            {
                s1 = String.Empty;
                sb.Clear();
                int low = 0;
                for (; low < 0x100; low++)
                {
                    sb.Append((char)(low|(high << 8)));
                }
                s1 = sb.ToString();
                _p.UserData = s1;
                string s2 = _p.UserData;
                Assert.AreEqual(s1, s2);//测试到 high = 0xD8 出错
            }

Original issue reported on code.google.com by [email protected] on 6 Dec 2012 at 1:57

多个手机向短信平台发送数字1,然后有短信平台判断只要发来的是数字1,那么就返回数字2,如果两个手机同时发送,则会报错(SendMsg的foreach时)。

需求:多个手机向短信平台发送数字1,然后短信平台判断只�
��发来的是数字1,那么就返回数字2
如果多个手机发送时间间隔长,下列代码没问题,可以运行��
�如果多个手机一起发(两个手机就能测试出来),则在SendMsg
的foreach时会报错。

#region 串口接收 事件
        private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            PDUEncoding pe = new PDUEncoding();
            string temp = serialPort1.ReadLine();//读取一行
            if (temp.Length > 8)
            {
                int int_NewMsgIndex = Convert.ToInt32(temp.Split(',')[1]);//获取短信号
                string str_NewMsg_Ori = ReadMsgByIndex(int_NewMsgIndex);//获取短信原始内容
                string str_NewMsg = pe.PDUDecoder(str_NewMsg_Ori).SmsContent;//短信解码内容
                string str_Phone = pe.PDUDecoder(str_NewMsg_Ori).PhoneNumber;//电话号码


                if (temp.Substring(0, 6) == "+CMTI:")//收到短信标记
                  {
                    //发送1,返回2
                    if (str_NewMsg.Trim() == "1")
                    {
                        SendMsg(str_Phone, "2");
                    }                    }
                }
                DeleteMsgByIndex(int_NewMsgIndex);
            }
        }
        #endregion

        #region 发送短信
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="phone">号码</param>
        /// <param name="msg">内容</param>
        public void SendMsg(string phone, string msg)
        {
            PDUEncoding pe = new PDUEncoding();
            pe.ServiceCenterAddress = "8613800311500";
            string tmp = string.Empty;
            foreach (CodedMessage cm in pe.PDUEncoder(phone, msg))//运行到该行时会报错
            {
                try
                {
                    //注销事件关联,为发送做准备
                    serialPort1.DataReceived -= serialPort1_DataReceived;
                    //信息字符数
                    serialPort1.Write("AT+CMGS=" + cm.Length.ToString() + "\r");

                    //定位到>
                    serialPort1.ReadTo(">");

                    //清除接收缓冲区数据
                    serialPort1.DiscardInBuffer();
                    //事件重新绑定 正常监视串口数据
                    serialPort1.DataReceived += serialPort1_DataReceived;
                    //发送数据
                    tmp = SendAT_No_Rec(cm.PduCode + (char)(26));//26 Ctrl+Z ascii码
                    //string a = cm.PduCode;
                    //lb_Message.Text = pe.PDUDecoder(a).SmsContent;
                }
                catch (Exception)
                {
                    throw new Exception("短信发送失败");
                }
                if (tmp.Contains("OK"))
                {
                    continue;
                }

                throw new Exception("短信发送失败");
            }
        }
        #endregion

Original issue reported on code.google.com by [email protected] on 27 Sep 2011 at 12:16

超时报错

System.Exception: 短信发送失败:System.TimeoutException: The operation has 
timed out.
   at System.IO.Ports.SerialStream.Read(Byte[] array, Int32 offset, Int32 count, Int32 timeout)
   at System.IO.Ports.SerialStream.Read(Byte[] array, Int32 offset, Int32 count)
   at System.IO.Ports.SerialPort.InternalRead(Char[] buffer, Int32 offset, Int32 count, Int32 timeout, Boolean countMultiByteCharsAsOne)
   at System.IO.Ports.SerialPort.ReadTo(String value)
   at GSMMODEM.MyCom.ReadTo(String value) in D:\project\SMS\gsmmodem\src\GSMMODEM\MyCom.cs:line 201
   at GSMMODEM.GsmModem.SendMsg(String phone, String msg) in D:\project\SMS\gsmmodem\src\GSMMODEM\GsmModem.cs:line 453
   at GSMMODEM.GsmModem.SendMsg(String phone, String msg) in D:\project\SMS\gsmmodem\src\GSMMODEM\GsmModem.cs:line 463

Original issue reported on code.google.com by [email protected] on 22 Oct 2012 at 1:37

Error happened when receiving new sms

I checked out the latest version, the send function is perfect, thank you very 
much. :-)

The problem is, the following error occurred when I try to receive the new 
message:

8/4/2013 10:07:11 PM:ReadNewMsg: Exception:System.Exception: Index and length 
must refer to a location within the string.
Parameter name: length PDU:
   at GSMMODEM.PDUEncoding.PDUDecoder(Int32 SmsIndex, String strPDU) in D:\Source\gsmmodem-read-only\src\GSMMODEM\PDUEncoding.cs:line 726
   at GSMMODEM.GsmModem.ReadMsgByIndex(Int32 index) in D:\Source\gsmmodem-read-only\src\GSMMODEM\GsmModem.cs:line 599
   at GSMMODEM.GsmModem.ReadNewMsg(Int32& sMsgIndex) in D:\Source\gsmmodem-read-only\src\GSMMODEM\GsmModem.cs:line 557
   at 短信猫.Form1.button5_Click(Object sender, EventArgs e) in D:\Source\gsmmodem-read-only\Samples\Sample\Form1.cs:line 225

What steps will reproduce the problem?
1. Connect COM3, and 9660
2. Send a new msg
3. click read new message

What is the expected output? What do you see instead?
The receive function should be normal

What version of the product are you using? On what operating system?
gsmmodem revision 34;  OS: windows 7

Please provide any additional information below.
I guess the reason is I am in Australia, our sms center format is like:  
0410066900, and our mobile number is like that format (0412345678  - 10 digits 
and start with 0 ) as well. The format is a little bit different with China.

Thank you very much for your help.

Cheers

Johnny Chen (I am a Chinese as well :-))


Original issue reported on code.google.com by [email protected] on 4 Aug 2013 at 12:21

PDUEncoding.cs中PDUUSC2Encoder问题

不用dll文件,将CodedMessage.cs、DecodedMessage.cs、PDUEncoding.cs直接�
��贴到项目中,当用sendmsg发送长短信时(假使分两条发送)下�
��result.Add(PDUUSC2Encoder.cs 的PDUUSC2Encoder方法中)会增加第三条
  //不是长短信
                ProtocolDataUnitType = "11";
                UserData = Text;
                result.Add(new CodedMessage(serviceCenterAddress + protocolDataUnitType
                    + messageReference + destinationAddress + protocolIdentifer
                    + dataCodingScheme + validityPeriod + userDataLenghth + userData));
暂时解决方法,将上面代码套在else{}里面,同样的问题也出��
�在PDU7BitEncoder方法中。

Original issue reported on code.google.com by [email protected] on 17 Sep 2011 at 3:13

发送成功,但是返回出错

读取超时最可能是
public GsmModem(string comPort, int baudRate)
        {
            _com = new MyCom();

            _com.PortName = comPort;          //
            _com.BaudRate = baudRate;
            _com.ReadTimeout = 10000;         //读超时时间 发送短信时间的需要
            _com.RtsEnable = true;            //必须为true 这样串口才能接收到数据

            _com.DataReceived += new EventHandler(sp_DataReceived);
        }
的_com.ReadTimeout = 
10000;不够大;不过10000时间是10s,一条短信发送10s应该够长了
,你可以把他加大点试下15等,看加到多少,可以不再出现超
时

Original issue reported on code.google.com by [email protected] on 24 Jun 2011 at 12:40

请添加超时限制

当在向Com发送指令时,如果没有返回结果,程序会一直处在��
�环之中,这样显然不行。
解决办法:应该在等待返回结果时添加超时检查。


     //接收数据 循环读取数据 直至收到“OK”或“ERROR”
            try
            {
                string temp = string.Empty;
                while (temp.Trim() != "OK" && temp.Trim() != "ERROR")
                {
                    //××××××××这里
                    temp = _com.ReadLine();
                    result += temp;
                }
                return result;
            }
我已经做过修改,可以更新吗?

Original issue reported on code.google.com by [email protected] on 19 Oct 2011 at 2:51

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.