Hi all,
thanks in advance for reading this post and helping me find a solution.
Ok,
I have a program that sends a SMS message via an attached GSM modem.
The program currently scans all attached serial ports and puts them into a comboBox list for the user to select which one to use.
This works fine, except that the user has to know which port to use.
I would like to query all ports to see if they respond correctly to SMS mode prior to including them into the comboBox list.
Here's the current code I have:
******************************************************
private void Form1_Load(object sender, EventArgs e)
{
lblStatus.Text = "";
cmbPhoneNum.DropDownStyle = ComboBoxStyle.DropDownList;
cmbBoxPorts.DropDownStyle = ComboBoxStyle.DropDownList;
//
// Find out a way to:
// 1. Check each serial port for response to SMS mode
// 2. Only display serial ports that are SMS capable
//
// Until then, this routine displays all serial ports
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
cmbBoxPorts.Items.Add(port);
}
try
{
cmbBoxPorts.SelectedIndex = 0;
}
catch { }
**********************************************
The AT command for SMS mode is:
AT+CMGF=1
*****************************************
I'm just a bit lost as to how to write the code to send this query to each attached serial port, get all the OK acks back and then only put the relevant ports in the list.
Thanks heaps
Andy
Loading
Mike GoldPosted Oct 3, 2010, 11:41 PM
Posted Oct 3, 2010, 6:23 AM
Mike didn't say "he doesn't know", he was making fun of my question, PERIOD!
Like you say:
"Criticizing people trying to help you is counter-productive. "
So Mike trying to make me look like a fool in the way he did is absolutely counter-productive to what I assumed this forum was about.
And you taking the "high-road" trying to mask low-ball humor as genuine feed-back is not fooling anyone.
What on earth do you mean:
"If you ask more specific questions you will get more specific answers, and please don't put many questions in one thread. "
I asked ONE VERY SPECIFIC question, that I was subjected to ridicule for by Mike.
If that's the kind of response that Moderators are happy to "go-to-bat" for, then I was genuinely mistaken as to the purpose of this forum.
I honestly thought that this forum was to help genuinely interested people to better understand the C# lanuage.
You know, some of us are not blessed with rich parents who can afford to send them to rich schools with computer studies and the like.
Some of us genuinely are looking around for genuine answers, NOT RIDICULE!
Sam, the ONLY thing that has assisted me is that you mentioned the term:
"device enumeration"
and as a beginner, I have no idea what this means, but at least I now know that someone with more knowledge believes that this may offer some assistance to me in furthering my understanding of programming.
At least THAT was of assistance.
Sam HobbsPosted Oct 1, 2010, 7:00 PM
People asking questions often ask a lot. This often ask how to do something and then something else and then oh and also they need more. People should ask how to do specific tasks, not the entire project. If you ask more specific questions you will get more specific answers, and please don't put many questions in one thread.
One task is for scanning for available ports. Just doing that much is a large request and unusual enough that people here just might not have experience with it. The next task is to send the analysis command and getting a response. Serial communication is not as easy as I/O for disk drive files.
Try searching for device enumeration articles and samples.
Posted Oct 1, 2010, 8:17 AM
that's 'king funny dude; nice one.
But honestly,
I'm just a beginner, so if you just want to "take the Mick" then I'm glad I was of some amusement to you.
Other than that, if someone would like to help me understand how to program this problem in C#, I'd be so very grateful.
Cheers
Andy
Mike GoldPosted Sep 30, 2010, 10:33 AM
Posted Sep 30, 2010, 8:09 AM
Thanks
Andy
Posted Sep 28, 2010, 7:08 AM
I really am a NEWBIE with all programming and I'm trying to learn what I can from the internet and other people's examples & assistance.
I guess I was looking for something a little more literal. The program already writes and reads from the comm port, but what I was hoping to achieve was a way to ask each comm port if it is able to work in SMS mode, then fill my comboBox list with only those comm ports that report OK to SMS mode.
If I were to write it in plain english step-by-step, it would look something like:
1. Query computer to get list of all comm ports attached to computer
2. Ask each comm port in turn if they can operate in SMS mode
2a. Question = AT+CMGF=1
2b. Affirmative Answer = OK
3. Create a list of each comm port that responded in the affirmative
4. Fill my comboBox with only those comm ports that are on the affirmative list
As you can see from the current code, the comboBox "cmbBoxPorts" is popuated by every port on the computer, but I would like to implement the above logic to only have SMS capable comm ports included in the "cmbBoxPorts".
I hope this better explains what I was hoping to achieve.
Thanks again
Andy
Mike GoldPosted Sep 26, 2010, 11:27 PM
http://www.c-sharpcorner.com/UploadFile/mgold/3347/Default.aspx
For example, to write the command to the port, it's probably
_port.Write("AT+CMFG=1");
you could then set a timer to allow a specific amount of time to get a response. I also suspect that if try to open or write to a port that is connected to nothing, you might get an exception, so you'll need to handle the exception in this case.