Click here to Skip to main content
15,992,524 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing serial port data receive and sending software in C#.My software work fine if i am not connected it with any USB device but when i connect my software with any USB device and send or receive data then i will not work is then any other code for receive USB connected device data.
I use this code for receive data:

C#
void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                if (comPort.IsOpen == true)
                {
                    bytes = comPort.BytesToRead;
                    comBuffer = new byte[bytes];
                    comPort.Read(comBuffer, 0, bytes);
                }
            }
            catch (Exception ex)
            {
            }
        }  

Help me to solve this.

[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]
Posted
Updated 21-Feb-12 5:02am
v2

Write comPort.DtrEnable = true; where serial port initialize.
 
Share this answer
 
This code will only work is the USB device you're connecting to exposes itself as a COM port (Serial device).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900