using System;I2C App
using System.Collections.Generic;
using
System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSharp_I2CApp
{
    public partial class Form1 : Form
    {
       
public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            I2CControl1.PortName = I2CControl1.GetPortNames()[1];
            I2CControl1.Open();
        }

       
private void I2CControl1_I2CMessage(object sender, EventArgs e)
        {
            richTextLogger.Invoke(
new EventHandler(Serial_DataRecieved));
        }

       
private void Serial_DataRecieved(object s, EventArgs e)
        {
           
byte[] I2CMessage = new byte[I2CControl1.Len];
            I2CControl1.Read(I2CMessage);
           
string newmessage = I2CControl1.TimeStamp.ToString("hh:mm:ss:fff") + " ";

           
foreach (byte I2CByte in I2CMessage)
                newmessage += I2CByte.ToString(
"X2");
            richTextLogger.AppendText(newmessage + System.
Environment.NewLine);
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            I2CControl1.Close();
        }
    }
}

amexmastercardvisajcbmaestrodiscoverpaypal
powered by stripe     PayPal Logo
Copyright © 2001-2018 AVIT Research ltd. Last modified: 25/06/19
ISO 9001:2015 Certified