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 communication

serial communication

Scheduled Pinned Locked Moved C#
helpiot
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.
  • G Offline
    G Offline
    George_Lucian
    wrote on last edited by
    #1

    ... i have a problem communicating on the serial port(COM1 or COM2).Here's the code: private void Form1_Load(object sender, EventArgs e) { if (!serialPort1.IsOpen) serialPort1.Open(); serialPort1.DtrEnable = true; } private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e { MessageBox.Show(serialPort1.ReadExisting()+"geo"); textBox1.Invoke(new EventHandler(delegate { textBox1.Text += serialPort1.ReadExisting();})); } ...if I connect pin2 with pin3 of the serial port(RX,TX),and i try to transmit something on the serial port, it works(the serialPort1_DataReceived event is raised and i get the data i have sent)...but when i connect a sensor(for a remote control) on the serial port and a push a button on the remote nothing happens. the sensor works because i have tested it with a special program named GIRDER(when i push a button on the remote it shows the code of the button on the screen). If someone could help i would appreciate it.

    S 1 Reply Last reply
    0
    • G George_Lucian

      ... i have a problem communicating on the serial port(COM1 or COM2).Here's the code: private void Form1_Load(object sender, EventArgs e) { if (!serialPort1.IsOpen) serialPort1.Open(); serialPort1.DtrEnable = true; } private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e { MessageBox.Show(serialPort1.ReadExisting()+"geo"); textBox1.Invoke(new EventHandler(delegate { textBox1.Text += serialPort1.ReadExisting();})); } ...if I connect pin2 with pin3 of the serial port(RX,TX),and i try to transmit something on the serial port, it works(the serialPort1_DataReceived event is raised and i get the data i have sent)...but when i connect a sensor(for a remote control) on the serial port and a push a button on the remote nothing happens. the sensor works because i have tested it with a special program named GIRDER(when i push a button on the remote it shows the code of the button on the screen). If someone could help i would appreciate it.

      S Offline
      S Offline
      Squeaker
      wrote on last edited by
      #2

      You need to set up your serial port so that all serial parameters match the parameters of the sensor that you are trying to communicate with. This includes baud rate, start bits, stop bits, parity, etc. If you don't have a datasheet that gives you these parameters, you will have to do some experimentation. I would suggest that you get a simple terminal program so that you can easily verify operation. I recommend Br@y terminal. Only because it is very lightweight, and it lets you set all parameters from the main screen. Once you know all the serial parameters, it should be easy to get your program to work. There are many good example of serial software on CP that will help you. Also, once you get Br@y terminal to work with your sensor, you can test your code with Br@y. -squeaker-

      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