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. Product Lifecycle
  3. Free Tools
  4. C# Communication

C# Communication

Scheduled Pinned Locked Moved Free Tools
csharptutoriallearning
3 Posts 3 Posters 4 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.
  • U Offline
    U Offline
    User 14013003
    wrote on last edited by
    #1

    Hello,
    I am a beginner in C #, I would like to know if there is a way and how to establish a conexion between a Winform interface and a measuring device in order to remotely control from a pc using a communication protocol (ModBus, RS232 etc)

    Thank you

    L R 2 Replies Last reply
    0
    • U User 14013003

      Hello,
      I am a beginner in C #, I would like to know if there is a way and how to establish a conexion between a Winform interface and a measuring device in order to remotely control from a pc using a communication protocol (ModBus, RS232 etc)

      Thank you

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please read the preamble at the top of the page, and use the correct forum for your question. From your question I would say that the answer will depend on the measuring device, so you need to consult the documentation.

      1 Reply Last reply
      0
      • U User 14013003

        Hello,
        I am a beginner in C #, I would like to know if there is a way and how to establish a conexion between a Winform interface and a measuring device in order to remotely control from a pc using a communication protocol (ModBus, RS232 etc)

        Thank you

        R Offline
        R Offline
        RedDk
        wrote on last edited by
        #3

        I'm not sure what THIS makes me but I'll go ahead and empty my clipboard (code copied from here GS - one of many[^] ). What I do when I have questions like yours is use Google. Sometimes there's nothing and I get flummoxed. Other times there's something which inspires me to continue working and not just pack it in for the day and get some exercise.

        using System;
        using System.IO.Ports;
        using System.Windows.Forms;

        namespace SerialPortExample
        {
        class SerialPortProgram
        {
        // Create the serial port with basic settings
        private SerialPort port = new SerialPort("COM1",
        9600, Parity.None, 8, StopBits.One);

        \[STAThread\]
        static void Main(string\[\] args)
        { 
          // Instatiate this class
          new SerialPortProgram();
        }
        
        private SerialPortProgram()
        {
          Console.WriteLine("Incoming Data:");
        
          // Attach a method to be called when there
          // is data waiting in the port's buffer
          port.DataReceived += new 
            SerialDataReceivedEventHandler(port\_DataReceived);
        
          // Begin communications
          port.Open();
        
          // Enter an application loop to keep this thread alive
          Application.Run();
        }
        
        private void port\_DataReceived(object sender,
          SerialDataReceivedEventArgs e)
        {
          // Show all the incoming data in the port's buffer
          Console.WriteLine(port.ReadExisting());
        }
        

        }
        }

        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