2

am doing some surveillance project... i need to make some serialport data communication between two systems ... here i could find available com ports in my system through which i need to send and receive some data...is it possible in .net framework 1.1 ? is there is any option?

System.IO.Ports is not available .net 1.1

5
  • 2
    -1 for caps and not taking the time to properly format your question into coherent sentences. If you want help, have the decency to phrase your question like a human being. Commented Jul 6, 2009 at 4:47
  • 2
    Its not fair to down vote if formatting is the reason. Commented Jul 6, 2009 at 4:52
  • 1
    english could not be his mother language Commented Jul 6, 2009 at 4:56
  • But even a spell checker would have detected those spelling mistakes ... Bad grammar is acceptable for non-english speakers but spelling is much less forgivable. Commented Jul 6, 2009 at 6:24
  • "Text Speak" and "Tweet Speak" are OK on StackOverflow. meta.stackexchange.com/questions/215908/…. If you have an objection, then its up to you to fix and not the person with writing it. (Personally, I disagree, but who am I...). Commented Jan 14, 2014 at 11:33

3 Answers 3

2

When I needed to do some serial port work back in 1.1, I found an article written by Noah Coad that uses the MSComm OCX control and that ended up working for me. You can find his article at http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=320. Good luck!

Sign up to request clarification or add additional context in comments.

Comments

1

For .net 1.1 I used OpenNETCF.IO.Serial because serial support was added to .net in version 2.0. It is for the compact framework but I used it for both compact devices and regular windows apps. You get the source code so you can modify it yourself which is what I did.

It basically creates a c# wrapper around the serial function imported out of kernel32.dll.

You might also want to have a look at How to capture a serial port that disappears because the usb cable gets unplugged

Here is the code that I used to call it

     using OpenNETCF.IO.Serial;

     public static Port port;
     private DetailedPortSettings portSettings;
     private Mutex UpdateBusy = new Mutex();

     // create the port
     try
     {
        // create the port settings
        portSettings = new HandshakeNone();
        portSettings.BasicSettings.BaudRate=BaudRates.CBR_9600;

        // create a default port on COM3 with no handshaking
        port = new Port("COM3:", portSettings);

        // define an event handler
        port.DataReceived +=new Port.CommEvent(port_DataReceived);

        port.RThreshold = 1;    
        port.InputLen = 0;      
        port.SThreshold = 1;    
        try
        {
           port.Open();
        }
        catch
        {
           port.Close();
        }
     }
     catch
     {
        port.Close();
     }

     private void port_DataReceived()
     {

        // since RThreshold = 1, we get an event for every character
        byte[] inputData = port.Input;

        // do something with the data
        // note that this is called from a read thread so you should 
        // protect any data pass from here to the main thread using mutex
        // don't forget the use the mutex in the main thread as well
        UpdateBusy.WaitOne();
        // copy data to another data structure
        UpdateBusy.ReleaseMutex();

     }

     private void port_SendBuff()
     {
        byte[] outputData = new byte[esize];
        crc=0xffff;
        j=0;
        outputData[j++]=FS;
        //  .. more code to fill up buff
        outputData[j++]=FS;
        // number of chars sent is determined by size of outputData
        port.Output = outputData;
     }

     // code to close port
     if (port.IsOpen)
     {
        port.Close();
     }
     port.Dispose();

1 Comment

Okay, so where's the juicy part (the port_DataReceived())?
0

Are you constrained to .NET 1.1? If .NET 2.0 is available to you, you can use the SerialPort.GetPortNames method to retrieve a list of serial ports on the local host. The SerialPort class is in the System.IO.Ports namespace.

1 Comment

System.IO.Ports is not in .net 1.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.