Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem with serialport

Posted on 2009-04-19
4
Medium Priority
?
375 Views
Last Modified: 2012-05-06
Hello,
I'm having a very big problem with the serialport class and I need some help to solve this.

we're using multiple serialports in a generic list since we need to connect to multiple devices.

This is what our basic code looks like...
 List<SerialPort> ports = new List<SerialPort>();
        private void button1_Click(object sender, EventArgs e)
        {
            ports.Add(new SerialPort("COM6"));
            ports.Add(new SerialPort ("COM7"));
            ports.Add(new SerialPort("COM8"));
            foreach (SerialPort port in ports)
            {
                port.Open();
            }
        }



Now,after the button is clicked,...if one of the devices(mobile phone in our case)  is switched off or if its cable is disconnected from the USB port,there is an immediate massive memory leakage.

Please help us with a solution.

I have noticed a similar thread here...
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_23315204.html
and a couple of bug reports in Microsoft Connect.
But,right now I need some IMMEDIATE URGENT solution.
Thanks so much
List<SerialPort> ports = new List<SerialPort>();
        private void button1_Click(object sender, EventArgs e)
        {
            ports.Add(new SerialPort("COM6"));
            ports.Add(new SerialPort ("COM7"));
            ports.Add(new SerialPort("COM8"));
            foreach (SerialPort port in ports)
            {
                port.Open();
            }
        }

Open in new window

0
Comment
Question by:godwindotnet
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
abel earned 750 total points
ID: 24178676
If you want an urgent solution, I suggest you read into this article: http://www.codeproject.com/KB/WCF/SerialComm.aspx. It explains in quite great detail how you can deal with COM ports the professional way and it comes with a demo project that you can use.

-- Abel --
0
 

Author Comment

by:godwindotnet
ID: 24178988
The demo project doesn't seem to work with a GSM modem.
For some reason,the onCom event never gets fired at all.
0
 
LVL 39

Expert Comment

by:abel
ID: 24178996
Hmm, that's a pity. Unfortunately I am not able to mimic your situation here. Perhaps somebody else can help you out or you can ask the moderators to add the zones about GSM/Mobile computing to get attention of other experts.
0
 
LVL 6

Assisted Solution

by:alex_paven
alex_paven earned 750 total points
ID: 24214799
I've hit a similar problem a while ago, and partially solved it using DesktopSerialIO, but be warned, this library also comes with problems of its own. Multiple serial ports in .Net seems to still be a nightmare for the moment, especially with USB-convertors; another solution would be to use a serial hub/server (like these, some of which I've used successfully), but those depend on their drivers and may also have issues.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question