コード例 #1
0
ファイル: rtlsdr.go プロジェクト: cyoung/gortlsdr
// WriteEeprom writes data to the EEPROM.
func (dev *Context) WriteEeprom(data []uint8, offset uint8, leng uint16) (err error) {
	i := int(C.rtlsdr_write_eeprom((*C.rtlsdr_dev_t)(dev),
		(*C.uint8_t)(unsafe.Pointer(&data[0])),
		C.uint8_t(offset),
		C.uint16_t(leng)))
	switch {
	default:
		err = nil
	case i == -1:
		err = errors.New("device handle is invalid")
	case i == -2:
		err = errors.New("EEPROM size exceeded")
	case i == -3:
		err = errors.New("no EEPROM was found")
	case i < -4:
		err = errors.New("unknown error")
	}
	return
}
コード例 #2
0
ファイル: rtlsdr.go プロジェクト: nlefler/gortlsdr
// Write the device EEPROM
//
// data buffer of data to be written
// offset address where the data should be written
// len length of the data
//
// int rtlsdr_write_eeprom(rtlsdr_dev_t *dev, uint8_t *data, uint8_t offset, uint16_t len);
// rtlsdr_write_eeprom returns 0 on success, -1 if device handle is invalid,
// -2 if EEPROM size is exceeded, -3 if no EEPROM was found
func (c *Context) WriteEeprom(data []uint8, offset uint8, leng uint16) (err int) {
	return int(C.rtlsdr_write_eeprom((*C.rtlsdr_dev_t)(c.dev),
		(*C.uint8_t)(unsafe.Pointer(&data[0])),
		C.uint8_t(offset),
		C.uint16_t(leng)))
}