im920

package module
v0.0.0-...-b7b68ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2015 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GoDoc Build Status Coverage Status

go-im920

A Go library to control the interplan IM920

インタープラン株式会社様の920MHz無線モジュール、IM920用の制御ライブラリです。

Tested Environment

  • ThinkPad T440s(Windows 10) + IM315-USB-RX
  • Raspberry Pi 2 Model B

Status

  • α版です。API変更の可能性があります。
  • 一通りのコマンドに対応しています。

Usage

モジュール間の送受信には、あらかじめ通信対象とする送信モジュールのIDを登録する必要があります。
登録方法は 取扱説明書(ハードウェア編) の「7-7.送信モジュールIDの登録と消去」に記載があります。
また、「(2)SRIDコマンドによるIDの登録 」は本ライブラリの im920.AddRcvId() でも可能です。

基本的な使用方法は こちら をご参照下さい。 データ受信は こちら をご参照下さい。

References

Documentation

Overview

Example
package main

import (
	"fmt"
	"github.com/tomoya0x00/go-im920"
	"time"
)

func main() {
	// This test will not be run, it has no "Output:" comment.
	c := &im920.Config{Name: "COM4", ReadTimeout: 1 * time.Second}
	im, err := im920.Open(c)
	if err != nil {
		fmt.Printf("Failed to open: %s\n", err)
		return
	}
	defer im.Close()

	id, err := im.GetId()
	if err != nil {
		fmt.Printf("Failed to GetId: %s\n", err)
		return
	}
	fmt.Printf("ID: %v\n", id)

	/*
		    err = im.AddRcvId(0x0001)
			if err != nil {
				fmt.Printf("Failed to AddRcvId: %s\n", err)
				return
			}
	*/

	version, err := im.IssueCommandRespStr("RDVR", "")
	if err != nil {
		fmt.Printf("Failed to RDVR: %s\n", err)
		return
	}
	fmt.Printf("VERSION: %v\n", version)

	/*
		    err = im.DeleteAllRcvId()
			if err != nil {
				fmt.Printf("Failed to DeleteAllRcvId: %s\n", err)
				return
			}
	*/

	rids, err := im.GetAllRcvId()
	if err != nil {
		fmt.Printf("Failed to GetAllRcvId: %s\n", err)
		return
	}
	fmt.Printf("RIDS: %v\n", rids)

	/*
	   err = im.SetCh(2, false)
	   if err != nil {
	       fmt.Printf("Failed to SetCh: %s\n", err)
	       return
	   }
	*/

	ch, err := im.GetCh()
	if err != nil {
		fmt.Printf("Failed to GetCh: %s\n", err)
		return
	}
	fmt.Printf("CH: %v\n", ch)

	rssi, err := im.GetRssi()
	if err != nil {
		fmt.Printf("Failed to GetRssi: %s\n", err)
		return
	}
	fmt.Printf("RSSI: %v\n", rssi)

	err = im.SetCommMode(im920.LONG_MODE, false)
	if err != nil {
		fmt.Printf("Failed to SetCommMode: %s\n", err)
		return
	}

	mode, err := im.GetCommMode()
	if err != nil {
		fmt.Printf("Failed to GetCommMode: %s\n", err)
		return
	}
	fmt.Printf("MODE: %v\n", mode)

	data := []byte("0123456789")
	_, err = im.Write(data)
	if err != nil {
		fmt.Printf("Failed to write: %s\n", err)
		return
	}
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ch

type Ch uint8

type Config

type Config struct {
	Name        string
	ReadTimeout time.Duration
}

type IM920

type IM920 struct {
	// contains filtered or unexported fields
}

func Open

func Open(c *Config) (*IM920, error)

func (*IM920) AddRcvId

func (im *IM920) AddRcvId(id Id) (err error)

func (*IM920) Close

func (im *IM920) Close() error

func (*IM920) DeleteAllRcvId

func (im *IM920) DeleteAllRcvId() error

func (*IM920) GetAllRcvId

func (im *IM920) GetAllRcvId() (ids []Id, err error)

func (*IM920) GetCh

func (im *IM920) GetCh() (ch Ch, err error)

func (*IM920) GetCommMode

func (im *IM920) GetCommMode() (mode Mode, err error)

func (*IM920) GetId

func (im *IM920) GetId() (id Id, err error)

func (*IM920) GetRssi

func (im *IM920) GetRssi() (rssi Rssi, err error)

func (*IM920) IsBusyFunc

func (im *IM920) IsBusyFunc(f func() bool)

func (*IM920) IssueCommand

func (im *IM920) IssueCommand(cmd, param string) (resp []byte, err error)

func (*IM920) IssueCommandNormal

func (im *IM920) IssueCommandNormal(cmd, param string) error

func (*IM920) IssueCommandRespNum

func (im *IM920) IssueCommandRespNum(cmd, param string) (resp uint16, err error)

func (*IM920) IssueCommandRespNums

func (im *IM920) IssueCommandRespNums(cmd, param string) (resp []uint16, err error)

func (*IM920) IssueCommandRespStr

func (im *IM920) IssueCommandRespStr(cmd, param string) (resp string, err error)

func (*IM920) LastReadInfo

func (im *IM920) LastReadInfo() ReadInfo

func (*IM920) Read

func (im *IM920) Read(p []byte) (n int, err error)

func (*IM920) SetCh

func (im *IM920) SetCh(ch Ch, persist bool) (err error)

func (*IM920) SetCommMode

func (im *IM920) SetCommMode(mode Mode, persist bool) (err error)

func (*IM920) Write

func (im *IM920) Write(p []byte) (n int, err error)

type Id

type Id uint16

type Mode

type Mode uint8
const (
	FAST_MODE Mode = iota + 1
	LONG_MODE
)

type Node

type Node uint8

type ReadInfo

type ReadInfo struct {
	FromNode Node
	FromId   Id
	FromRssi Rssi
}

type Rssi

type Rssi uint8

Directories

Path Synopsis
examples
TxRx command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址