Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Passing data from C# to ComPort2 (USb to RS232)
Roi Florentino
Jan 17 2018 4:05 AM
146
Reply
I have a card dispensing device in which I want to be triggered by a C# program.
The Card Dispensing Device has a command to trigger the card-out function.
Now when I checked the 42 is a hex and the H is just a hex determinator of some sort.
They gave me an exe which do the sending of data but I want to repliacte it and create my own.
In the exe that they gave when I press card out it shows a command like this one
-->[0x01] [0x42]
the first [] is for the device the second [] is the I think ascii hex of the command.
Here's the code I have so far
using
System.IO.Ports;
namespace
Card_Reader
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
button1_Click(
object
sender, EventArgs e)
{
using
(SerialPort port =
new
SerialPort(
"COM2"
, 9600, Parity.None, 8))
{
byte
[] bytesToSend =
new
byte
[1] { 0x2A };
port.Open();
port.Write(bytesToSend, 0, 1);
}
}
I did not include all closing brackets.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
CrystalReport error??
inconsistent accessibility