Spike UK
asked on
Sending receiving text messages in vb.net
I can successfully send a text message via a modem (in vb.net 2012) but when I receive a message, the string that arrives is
vbCrLf & "+CMTI: ""SM"",20" & vbCrLf
Using
Private Sub SerialPort1_DataReceived(s ender As Object, e As SerialDataReceivedEventArg s) Handles SerialPort1.DataReceived
Dim recStr As String = String.Empty
Try
recStr = SerialPort1.ReadExisting
vbCrLf & "+CMTI: ""SM"",20" & vbCrLf
Using
Private Sub SerialPort1_DataReceived(s
Dim recStr As String = String.Empty
Try
recStr = SerialPort1.ReadExisting
OK. So what is the problem?
ASKER
The text I'm sending is to the modem is "test 1" when the message received is "vbCrLf & "+CMTI: ""SM"",20" & vbCrLf"
As you can successfully send that implies you can read from the modem. Have you checked exactly what you receive by this other method when you send your "test 1" message?
ASKER
I can send a message OK to a phone using the application written vb.Net.
When I send the "test1" messages to the modem, I then trigger the SerialPort1_DataReceived as expected.
However, when I using the ReadExisting method
recStr = SerialPort1.ReadExistingd.
the received message is : "vbCrLf & "+CMTI: ""SM"",20" & vbCrLf"
When I send the "test1" messages to the modem, I then trigger the SerialPort1_DataReceived as expected.
However, when I using the ReadExisting method
recStr = SerialPort1.ReadExistingd.
the received message is : "vbCrLf & "+CMTI: ""SM"",20" & vbCrLf"
is the speed of the sending and recieving modems set the same i.e. 19,200 8N1
ASKER
The sending and receiving modem is the same modem - I can send OK, and the message is received but I can't read it.
When I read the data from the serial port using the method ReadExisting I just get
"vbCrLf & "+CMTI: ""SM"",20" & vbCrLf" where the number (in this case 20)
which I believe is the number if stored messages,
The modem is set up as follows:
SerialPort1.DtrEnable = True
SerialPort1.BaudRate = 115200
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.NewLine = Chr(13)
When I read the data from the serial port using the method ReadExisting I just get
"vbCrLf & "+CMTI: ""SM"",20" & vbCrLf" where the number (in this case 20)
which I believe is the number if stored messages,
The modem is set up as follows:
SerialPort1.DtrEnable = True
SerialPort1.BaudRate = 115200
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.NewLine = Chr(13)
The sending and receiving modem ate the same modem Say WHAT?? do you have a loopback plug attached to the modem?
ASKER
No - I'm sending SMS messages from the modem to a phone.
I am also sending messages to the modem from a phone.
I am also sending messages to the modem from a phone.
You've got me there.. what type of modem are you using? I'm only familiar with modem's that are attached to a telephone line.and I haven't used a modem since about 1999 and I don't know of a service that you can via a dialup modem send an sms message or recieve an sms message, please enlighten me.
Have you tried just using a terminal program to see what results you get?
Have you tried just using a terminal program to see what results you get?
ASKER
It's a Sierra Wireless modem attached to a laptop via a USB cable, controlled through a Serial Port. It was being used on a Windows 98 server previous using similar software.
and you are connecting to which service? Ok now I have an idea of what you are using.. so you have put in a sim card and are subscribed to a service ??
ASKER
Yes- It's a modem containing a SIM card. I am using AT commands to control it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried using terminal program I could see all the messages stored i the modem using AT+CMGL="ALL"
I've retried in the application and sent a message from the phone to it.
I can now read the received messages!
I'm not sure what using a terminal Emulator did but it appears fixed!
I've retried in the application and sent a message from the phone to it.
I can now read the received messages!
I'm not sure what using a terminal Emulator did but it appears fixed!
ASKER
I'm not sure why running the commands through an emulator fixed it, but its now working!