Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. serial port data read

serial port data read

Scheduled Pinned Locked Moved C#
csharplinqcomgraphicshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 10263519
    wrote on last edited by
    #1

    hi' am developing project on hand held system,my view is : select the file(excel)by clicking browse. then click on upload. here it's going to that device but after receiving data that device needs to send "$OK#" back to my program how can i receive that . plz help how to do tha

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Excel=Microsoft.Office.Interop.Excel;
    using System.IO;
    using System.Threading;
    using System.IO.Ports;

    namespace Hand_Held_Data_Transporter
    {
    public partial class Form1 : Form
    {
    int[] stream_buffer;

        /\*private static Microsoft.Office.Interop.Excel.Workbook mWorkBook;
        private static Microsoft.Office.Interop.Excel.Sheets mWorkSheets;
        private static Microsoft.Office.Interop.Excel.Worksheet mWSheet1;
        private static Microsoft.Office.Interop.Excel.Application oXL;\*/
    
        public Form1()
        {
            InitializeComponent();
            progressBar1.Enabled = false;
            progressBar2.Enabled = false;
    
            serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serialPort1\_DataReceived);
           
        }
    
    
    
        private void Browse\_Click(object sender, EventArgs e)
        {
    
            OpenFileDialog fdlg = new OpenFileDialog();
            fdlg.Filter = "All Files(\*.\*)|\*.\*";
            if (fdlg.ShowDialog() == DialogResult.OK)
            {
    
    
                textBox1.Text = fdlg.FileName;
                File.ReadAllText(textBox1.Text);
    
            }
        }
    
       
    
    
    
        private void Upload\_Click(object sender, EventArgs e)
        {
    
           // StringBuilder sb = new StringBuilder();
    
    
            Excel.Application xlApp = new Excel.Application();
            Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(textBox1.Text, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\\t", false, false, 0, true, 1, 0);
            Excel.\_Worksheet xlWorksheet = (Excel.\_Worksheet)xlWorkbook.Sheets\[1\];
            Excel.Range xlRange = xlWorksheet.UsedRange;
    
            int rowCount = xlRange.Rows.Count;
            int colCount = xlRange.Columns.Count;
            progressBar1.Visible = true;
            
    
            int k = 100 / rowCount;
    
            for (int i = 1; i <= rowCount; i++)
            {
    
                String
    
    M 1 Reply Last reply
    0
    • M Member 10263519

      hi' am developing project on hand held system,my view is : select the file(excel)by clicking browse. then click on upload. here it's going to that device but after receiving data that device needs to send "$OK#" back to my program how can i receive that . plz help how to do tha

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;
      using Excel=Microsoft.Office.Interop.Excel;
      using System.IO;
      using System.Threading;
      using System.IO.Ports;

      namespace Hand_Held_Data_Transporter
      {
      public partial class Form1 : Form
      {
      int[] stream_buffer;

          /\*private static Microsoft.Office.Interop.Excel.Workbook mWorkBook;
          private static Microsoft.Office.Interop.Excel.Sheets mWorkSheets;
          private static Microsoft.Office.Interop.Excel.Worksheet mWSheet1;
          private static Microsoft.Office.Interop.Excel.Application oXL;\*/
      
          public Form1()
          {
              InitializeComponent();
              progressBar1.Enabled = false;
              progressBar2.Enabled = false;
      
              serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serialPort1\_DataReceived);
             
          }
      
      
      
          private void Browse\_Click(object sender, EventArgs e)
          {
      
              OpenFileDialog fdlg = new OpenFileDialog();
              fdlg.Filter = "All Files(\*.\*)|\*.\*";
              if (fdlg.ShowDialog() == DialogResult.OK)
              {
      
      
                  textBox1.Text = fdlg.FileName;
                  File.ReadAllText(textBox1.Text);
      
              }
          }
      
         
      
      
      
          private void Upload\_Click(object sender, EventArgs e)
          {
      
             // StringBuilder sb = new StringBuilder();
      
      
              Excel.Application xlApp = new Excel.Application();
              Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(textBox1.Text, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\\t", false, false, 0, true, 1, 0);
              Excel.\_Worksheet xlWorksheet = (Excel.\_Worksheet)xlWorkbook.Sheets\[1\];
              Excel.Range xlRange = xlWorksheet.UsedRange;
      
              int rowCount = xlRange.Rows.Count;
              int colCount = xlRange.Columns.Count;
              progressBar1.Visible = true;
              
      
              int k = 100 / rowCount;
      
              for (int i = 1; i <= rowCount; i++)
              {
      
                  String
      
      M Offline
      M Offline
      Marco Bertschi
      wrote on last edited by
      #2

      Arduino, C#, and serial interface[^] Serial Comms in C# for Beginners[^] SO[^] Now you got the knowledge sources, start thinking and being productive!

      Veni, vidi, caecus

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups