bitscope

package module
v0.0.0-...-9edf9ab Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2014 License: ISC Imports: 5 Imported by: 0

README

bitscope

Go API for Bitscope BSNG (BS10, BS05). IN PROGRESS.

Documentation

Overview

Bitscope BSNG API.

This package will expose functionality of the BS10 and BS05 USB oscilloscopes from BitScope, while hiding the the virtual machine inside them.

See https://bitscope.com for more information on these PC oscilloscopes.

Example
bs, err := Open("")

if err != nil {
	log.Fatal(err)
}

defer bs.Close()

bs.Reset()

bs.Vertical("2v")
bs.Horizontal(1, 40) // 40/1 = 1MHz
bs.TriggerTiming(0, 0, 1)

bs.Trace(0, 1000, 0)

b, _ := bs.Dump(256)

println(len(b))

for i := 0; i < len(b); i++ {
	fmt.Printf("%02x ", b[i])
}
println("")
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scope

type Scope struct {

	// The ID string returned by the BitScope
	ID string
	// The model of the attached scope ('bs10' or 'bs05')
	Model string
	// contains filtered or unexported fields
}

func Open

func Open(dev string) (*Scope, error)

Open opens a connection to a BitScope instrument.

If the ID string returned by the BitScope is not recognized as one of the supported ones, an error is returned.

func (*Scope) Close

func (bs *Scope) Close() error

Close ends the connection to the BisScope

func (*Scope) Dump

func (bs *Scope) Dump(size uint) ([]byte, error)

Dump reads the data buffer from the BitScope into a byte array. This buffer contains the data acquired during the trace phase.

func (*Scope) Horizontal

func (bs *Scope) Horizontal(pre, div uint) error

Horizontal sets the time base/scale of the trace.

func (*Scope) Id

func (bs *Scope) Id() string

Id returns a string identifying the VM revision

Use bs.ID instead of this function unless you want a to explicitly ask the BitScope for its ID.

Example
bs, err := Open("")

if err != nil {
	log.Fatal(err)
}

defer bs.Close()

bs.Reset()

id := bs.Id()
if !strings.HasPrefix(id, "BS00") || len(id) != 8 {
	log.Fatal("Incorrect ID")
}

// If the serial channel is not properly configured, a second call to Id()
// may return characters from the previous request.
id = bs.Id()
if !strings.HasPrefix(id, "BS00") || len(id) != 8 {
	log.Fatal("Incorrect ID")
}
Output:

func (*Scope) Led

func (bs *Scope) Led(n, i uint)

Led controls the intensity of the 3 LEDs of the BS10, one at a time.

Example
bs, err := Open("")

if err != nil {
	log.Fatal(err)
}

defer bs.Close()

bs.Led('r', 0x10)
bs.Led('g', 0x80)
bs.Led('y', 0xc0)
Output:

func (*Scope) Reset

func (bs *Scope) Reset()

Reset instructs the BitScope to do a soft reset

func (*Scope) Stop

func (bs *Scope) Stop()

Stop terminates a command sequence

func (*Scope) Trace

func (bs *Scope) Trace(pre, post, delay uint) ([]byte, error)

Trace starts the data acquisition and waits until it has completed. The parameters pre and post are the pre-trigger and post-trigger number of samples, and the delay is specified in us. The delay is a time window after the trigger in which no samples are recorded.

func (*Scope) TraceTerminate

func (bs *Scope) TraceTerminate()

TraceTerminate is used to 'manually' end the data acquisition, instead of using a trigger event.

func (*Scope) Trigger

func (bs *Scope) Trigger(src, level uint)

Trigger sets the analog trigger to the specified channel and voltage threshold.

func (*Scope) TriggerLogic

func (bs *Scope) TriggerLogic(level, mask uint)

TriggerLogic sets the trigger to logic mode with the given bit levels and mask. The mask parameter identifies bits whose state is to be ignored by the trigger comparator.

func (*Scope) TriggerMode

func (bs *Scope) TriggerMode(mod, edge, comp bool)

TriggerMode sets the mode (level or edge), edge (0->1 or 1->0), and hardware comparator (active or not).

TODO: invert, swap: ??

func (*Scope) TriggerTiming

func (bs *Scope) TriggerTiming(hoff, hon, timeout uint)

TriggerTiming sets the timing parameters associated with a trigger.

For a trigger to be valid, the trigger condition must be false during hold-off, then true during hold-on. Also a timeout can be specified, for the case that the trigger event never happens.

Hold-off time: 0 .. 2^16; tick = 1/Fs Hold-on time: 0 .. 2^16; tick = 1/Fs Timeout: 0 .. 2^16; tick = 6.4 us. 0 = no timeout.

func (*Scope) Vertical

func (bs *Scope) Vertical(rng string) error

Vertical sets the voltage range of the trace.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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