Click here to Skip to main content
15,392,209 members
Home / Discussions / C#
   

C#

 
Questionserial port writing and reading Pin
khomeyni29-Jan-14 3:21
Memberkhomeyni29-Jan-14 3:21 
AnswerRe: serial port writing and reading Pin
Richard Andrew x6429-Jan-14 6:23
professionalRichard Andrew x6429-Jan-14 6:23 
GeneralRe: serial port writing and reading Pin
khomeyni29-Jan-14 6:37
Memberkhomeyni29-Jan-14 6:37 
AnswerRe: serial port writing and reading Pin
Richard Andrew x6429-Jan-14 6:44
professionalRichard Andrew x6429-Jan-14 6:44 
AnswerRe: serial port writing and reading Pin
Richard Andrew x6429-Jan-14 7:00
professionalRichard Andrew x6429-Jan-14 7:00 
GeneralRe: serial port writing and reading Pin
khomeyni30-Jan-14 4:34
Memberkhomeyni30-Jan-14 4:34 
GeneralRe: serial port writing and reading Pin
Richard Andrew x6430-Jan-14 7:59
professionalRichard Andrew x6430-Jan-14 7:59 
GeneralRe: serial port writing and reading Pin
khomeyni30-Jan-14 8:17
Memberkhomeyni30-Jan-14 8:17 
yes . excuse me. I'm decreasing it.

and this is the code for reading bytes:


C#
public void ThreadMain()
        {
            int i = 0;
            while (port.IsOpen)//while (port != null && port.IsOpen)
            {
                try
                {
                    var b1 = port.ReadByte();

                    if (b1 == ReadSignal.STARTByte)
                    {
                        //read  location 
                        b1 = port.ReadByte();
                        ...
                        if (b1 == ReadSignal.STOPByte)
                        {

                                RSignal.isValid = true;
                        }

                    }
                    if (RSignal.isValid)
                    {
                        RSignal.ExtractLocatoins();
                        if (DataReceived != null)
                            DataReceived.Invoke(RSignal);
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("1:"+ex.ToString()); 
                }
            }
        }



and code for writing:


C#
public void SendCommand(SerialPort port,byte[] command)//public void SendCommand(byte[] command)
        {

            if (port != null && port.IsOpen)
            {
               port.Write(command, 0, command.Length);
            }
            else
            {
                MessageBox.Show("port is not open!");
            }
        }

GeneralRe: serial port writing and reading Pin
Richard Andrew x6430-Jan-14 8:23
professionalRichard Andrew x6430-Jan-14 8:23 
GeneralRe: serial port writing and reading Pin
khomeyni30-Jan-14 8:26
Memberkhomeyni30-Jan-14 8:26 
AnswerRe: serial port writing and reading Pin
Richard Andrew x6430-Jan-14 8:34
professionalRichard Andrew x6430-Jan-14 8:34 
GeneralRe: serial port writing and reading Pin
khomeyni30-Jan-14 8:50
Memberkhomeyni30-Jan-14 8:50 
AnswerRe: serial port writing and reading Pin
Richard Andrew x6430-Jan-14 8:52
professionalRichard Andrew x6430-Jan-14 8:52 
GeneralRe: serial port writing and reading Pin
khomeyni30-Jan-14 8:59
Memberkhomeyni30-Jan-14 8:59 
AnswerRe: serial port writing and reading Pin
Richard Andrew x6430-Jan-14 9:06
professionalRichard Andrew x6430-Jan-14 9:06 
GeneralRe: serial port writing and reading Pin
khomeyni30-Jan-14 9:06
Memberkhomeyni30-Jan-14 9:06 
Questiondepicting data in c# in realtime Pin
khomeyni29-Jan-14 2:38
Memberkhomeyni29-Jan-14 2:38 
AnswerRe: depicting data in c# in realtime Pin
Eddy Vluggen29-Jan-14 2:59
professionalEddy Vluggen29-Jan-14 2:59 
GeneralRe: depicting data in c# in realtime Pin
khomeyni29-Jan-14 6:43
Memberkhomeyni29-Jan-14 6:43 
GeneralRe: depicting data in c# in realtime Pin
Eddy Vluggen29-Jan-14 8:01
professionalEddy Vluggen29-Jan-14 8:01 
GeneralRe: depicting data in c# in realtime Pin
khomeyni30-Jan-14 4:26
Memberkhomeyni30-Jan-14 4:26 
QuestionNeed help on chat between two computers Pin
larsp77729-Jan-14 1:20
Memberlarsp77729-Jan-14 1:20 
AnswerRe: Need help on chat between two computers Pin
OriginalGriff29-Jan-14 2:32
mveOriginalGriff29-Jan-14 2:32 
GeneralRe: Need help on chat between two computers Pin
larsp77729-Jan-14 2:43
Memberlarsp77729-Jan-14 2:43 
GeneralRe: Need help on chat between two computers Pin
OriginalGriff29-Jan-14 2:54
mveOriginalGriff29-Jan-14 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.