TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sameer Khan
1.5k
272
39.2k
How to read the sms from the usb dongle using C#
Sep 6 2017 2:37 AM
This is the code I have tried.
SerialPort _serialPort =
new
SerialPort(
"COM5"
, 9600);
_serialPort.Parity = Parity.None;
_serialPort.DataBits = 8;
_serialPort.Handshake = Handshake.RequestToSend;
_serialPort.DtrEnable =
true
;
_serialPort.RtsEnable =
true
;
_serialPort.NewLine = Environment.NewLine;
_serialPort.Open();
_serialPort.Write(
"AT"
+ System.Environment.NewLine);
Thread.Sleep(1000);
_serialPort.WriteLine(
"AT+CMGF=1"
+ System.Environment.NewLine);
Thread.Sleep(1000);
_serialPort.WriteLine(
"AT+CMGL=\"ALL\"\r"
+ System.Environment.NewLine);
Thread.Sleep(3000);
string
response = _serialPort.ReadExisting();
if
(response.EndsWith(
"\r\nOK\r\n"
))
{
Console.WriteLine(response);
}
else
{
Console.WriteLine(response);
}
Console.ReadLine();
String input =
"Data Source=10.31.8.107;Initial Catalog=WR_CWM_PR_Barrel_Bearing;User ID=sa;Password=server#qtr#15"
;
Regex r =
new
Regex(@
"\+CMGL: (\d+),"
"(.+)"
","
"(.+)"
",(.*),"
"(.+)"
"\r\n(.+)\r\n"
);
Match m = r.Match(_serialPort.ReadExisting());
while
(m.Success)
{
string
a = m.Groups[1].Value;
string
b = m.Groups[2].Value;
string
c = m.Groups[3].Value;
string
d = m.Groups[4].Value;
string
s = m.Groups[5].Value;
string
f = m.Groups[6].Value;
ListViewItem Item =
new
ListViewItem(
new
string
[] { a, b, c, d, s, f });
listView1.Items.Add(Item);
m = m.NextMatch();
}
Reply
Answers (
2
)
Combox that contains letters textboxs stop working
Format datagridview cell for decimal number