Coder Social home page Coder Social logo

can-isotp's Introduction

can-isotp

golang network can bus isotp protocol

简介

协议借鉴 Linux Kernel Module for ISO 15765-2:2016

例子

func main() {
	fmt.Println("Start")
	c, err := NewCan("can0")
	if err == nil {
		isotp.Init(c)
		if itp := isotp.IsoTP(128, 384); itp != nil {
			itp.ResetConfig(isotp.Config{STmin: 0x14, BS: 0x00}) // 每帧连续帧间隔20毫秒,不限制接收帧数,再无流控帧发送
			go func() {
				b := itp.ReadData()
				for b != nil {
					fmt.Println(string(b))
					b = itp.ReadData()
					fmt.Println("128, 384", itp.WriteData([]byte(code)))
				}
			}()
		}
		if itp := isotp.IsoTP(1, 257); itp != nil {
			itp.ResetConfig(isotp.Config{STmin: 0x0A, BS: 0x0F}) // 每帧连续帧间隔10毫秒接收16帧,然后等待下一帧流控帧
			go func() {
				b := itp.ReadData()
				for b != nil {
					fmt.Println(string(b))
					b = itp.ReadData()
					fmt.Println("1, 257", itp.WriteData([]byte(`func (c *Can) WriteFrame(frame can.Frame) error {
						_, err := c.rwc.Write(frame.WireFormat())
						return err
					}`)))
				}
			}()
		}

	}
	fmt.Println("End", err)
}

can-isotp's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.