Author Topic: Serial port control  (Read 488 times)

mplekker

  • Newbie
  • *
  • Posts: 10
    • View Profile
Serial port control
« on: September 15, 2022, 11:05:45 AM »
Hello,

I am trying to make an interface where you push a pushbutton on Advanced HMI and it will send an ASCII string (or other data) via one of the serial ports on the computer.  For example, this application will have several keys (pushbuttons) such as the "BasicButton" from the "AdvancedHMIControls Components" or the "Button" from the "All Windows Forms".  When you press that button I simply want to send a short string of data over one of the serial ports (or USB port that have a USB to DB9 converter) to a device that can be controlled serially.  Any ideas on what the best approach is for this?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Serial port control
« Reply #1 on: September 15, 2022, 03:18:27 PM »
- From the Toolbox, add a SerialPort to the MainForm
- Set the SerialPort properties
- Double click onto a blank area of the MainForm, this will take you to the Form Load event handler.
  Type in SerialPort1.Open()
- Go back to the MainForm design view
- From the Toolbox add a Button to the form
- Double click the button
- Enter
  SerialPort1.Send("ABC")