|
-
Jan 23rd, 2011, 08:50 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2008] Opening a virtual com port
I need to communicate with a BlackBerry cell phone, so that I can query the current signal strength using Hayes AT commands, and store is into a file, along with my current GPS position.
I already got it to work perfectly using HyperTerminal:
- I installed BlackBerry Desktop Manager and I leave it running on the PC (otherwise it does not work!)
- I connect my BlackBerry Bold cell phone to the PC using a USB cable.
-The cell phone appears on the PC as a Virtual Com port, in my case it shows up as "COM13".
- I open HyperTerminal and connect to COM13 at 115200 bauds, 8 bits, 1 stop bit, hardware flow control
- If I type "AT" + ENTER, the phone answers "OK"
- If I type "ATI1" + ENTER, the phone answers with its model number "Platform: X.X.X.X, App version: X.X.X.X, PIN: XXXXXXXX"
- If I type "AT+CSQ" + ENTER, the phone answers with the current signal quality value "+CSQ: 21,99".
In theory it should be a piece of cake to query my phone using a serial port routine in VB.NET. The problem I have is that VB.NET allows me to read data from a REAL COM PORT, but refuses to read anything from a VIRTUAL COM PORT. When opening "COM13", I get "The given port name does not start with COM/com or does not resolve to a valid serial port. Parameter name: portName".
I did a lot a searching on Virtual Com Port on the WEB, but everything I see allows me to create a virtual com port. I only want to read an existing VIRTUAL COM PORT, not create a new one.
Anyone with a BlackBerry should be able to try it without any problems, simply follow my steps to try it first using HyperTerminal, then try to do the same using a VB.NET program.
So, I do I actually open a VIRTUAL SERIAL PORT, so that I can send the "AT+CSQ" command and receive my cell phone signal strength value using VB.NET?
-
Jan 24th, 2011, 03:51 PM
#2
Fanatic Member
Re: [2008] Opening a virtual com port
Hi,
Try downloading EnhancedSerialPort.dll from my homepage. It is free. This includes a terminal emulator program. Run it. One of the enhancements is a PortDescriptions method that returns an array of descriptions, in addition to the actual serial port number. This may (or may not) be instructive. See: Software Downloads on www.hardandsoftware.net.
The SerialPort object has worked with every Virtual Serial Port driver that I have tried (those compatible with the OS; some VSPs are not usable under Vista or Windows 7).
Report back with your results. Since I don't have your hardware, I cannot do more than offer this suggestion.
Dick
Richard Grier, Consultant, Hard & Software
Microsoft MVP (Visual Basic)
-
Jan 24th, 2011, 05:55 PM
#3
Thread Starter
Hyperactive Member
Re: [2008] Opening a virtual com port
I already found your web site while GOOGLING during the weekend and it does not allow me to open a Virtual Com Port. Here is the error I get at the OPEN:
"System.ArgumentException: The given port name does not start with COM/com or does not resolve to a valid serial port.
Parameter name: portName
at System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
at System.IO.Ports.SerialPort.Open()
at EnhancedSerialPort.SerialPort.Open()
at TestEnhancedPort.TestEnhanced.PortOpenToolStripMenuItem_Click_1(Object sender, EventArgs e) in C:\TestEnhancedPort\Form1.vb:line 153"
BTW, with VB.NET 2008, I get 10 warnings in your module frmConfigScrn.vb at every reference to EnhancedSerialPort:
Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.
-
Jan 24th, 2011, 06:12 PM
#4
Fanatic Member
Re: [2008] Opening a virtual com port
Hi,
Sorry, I don't know the answer to your question -- Virtual Ports can be tricky, and Microsoft is using the standard serial APIs. EnhancedSerialPort is just a wrapper around the built-in SerialPort object (System.IO.Ports.SerialPort), so it will have the same "issues" opening a port as does the underlying SerialPort object.
My point was for you to open the Communcation menu Settings dialog and to report back what is displayed in the port descriptions listbox on the right side of the for. This is the information that is returned by the PortDescriptions method. This may be instructive.
Another question to answer is, "What does the GetPortsMethod() return?" This also is displayed in the Communications menu Settings dialog, in the listbox on the left side of the form.
BTW, the warnings that are displayed by Visual Studio are just areas of the code where the compiler "thinks" there may be a problem at some point. These warnings often may be ignored because they actually are covered by the design. For example, a call to the SerialPort.GetPorts() method always generates the warning, "Access of shared member, constant (etc.)... will not be evaluated." This is as expected, and is the source of most of the warnings that you see (similarly calls to the PortDescriptions() method).
Dick
Richard Grier, Consultant, Hard & Software
Microsoft MVP (Visual Basic)
-
Jan 25th, 2011, 03:57 AM
#5
Lively Member
Re: [2008] Opening a virtual com port
What creates COM13? If I plug a Serial to USB adapter into my pc Windows creates a virtual com port (COM6 in my case) and VB.net can get to it using the standard Port.Open on System.IO.Ports.SerialPort.
If you just plug the Blackberry into the PC with nothing else running, does windows create a new COM port?
-
Jan 25th, 2011, 08:12 AM
#6
Thread Starter
Hyperactive Member
Re: [2008] Opening a virtual com port
I also use serial-to-USB adapters and it works fine, then create a REAL serial port.
With the BlackBerry, it looks like a serial port, but it is not recognized as such.
Late last night I finally got something going. I downloaded Franson Serial Port DLL and it was able to open and read the data from my BlackBerry. With the AT commands, my VB.NET program can control most BlackBerry features like Signal strength, Dial calls, Answer calls, etc.
I still have to run the BlackBerry Destop Manager in the background, otherwise the serial port does not return any data to my VB.NET program.
Thanks for your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|