本文整理汇总了C++中readBytes函数的典型用法代码示例。如果您正苦于以下问题:C++ readBytes函数的具体用法?C++ readBytes怎么用?C++ readBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readBytes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readBytes
/**
* Handle calling a callback function that uses three bytes as parameters
* e.g. leds, pwmLowSideDrivers
*/
void OpenInterface::callCallbackWithThreeBytes(callbackWithThreeBytes callbackFunction)
{
uint8_t status[3];
bool result = readBytes(status, 3);
if (result && callbackFunction)
{
(*callbackFunction)(status[0], status[1], status[2]);
}
}
示例2: readBytes
/* Read device memory to extract current
accelerometer and gyroscope values. */
void MPU6050::read6dof(int* ax, int* ay, int* az, int* gx, int* gy, int* gz) {
readBytes(MPU6050_RA_ACCEL_XOUT_H, 14, buffer);
*ax = (((int)buffer[0]) << 8) | buffer[1];
*ay = (((int)buffer[2]) << 8) | buffer[3];
*az = (((int)buffer[4]) << 8) | buffer[5];
*gx = (((int)buffer[8]) << 8) | buffer[9];
*gy = (((int)buffer[10]) << 8) | buffer[11];
*gz = (((int)buffer[12]) << 8) | buffer[13];
}
示例3: readBytes
void LIS2MDL::readData(int16_t * destination)
{
uint8_t rawData[6]; // x/y/z mag register data stored here
readBytes(LIS2MDL_ADDRESS, (0x80 | LIS2MDL_OUTX_L_REG), 8, &rawData[0]); // Read the 6 raw data registers into data array
destination[0] = ((int16_t)rawData[1] << 8) | rawData[0] ; // Turn the MSB and LSB into a signed 16-bit value
destination[1] = ((int16_t)rawData[3] << 8) | rawData[2] ;
destination[2] = ((int16_t)rawData[5] << 8) | rawData[4] ;
}
示例4: readBytes
size_t DecompressG711ALaw::getSamples(AudioSample *buffer, size_t length)
{
AudioByte *byteBuff =
reinterpret_cast<AudioByte *>(buffer);
size_t read = readBytes(byteBuff,length);
for(long i=read-1; i>=0; i--)
buffer[i] = aLawDecodeTable[ byteBuff[i] ];
return read;
}
示例5: readBytes
int SE_BufferInput::readInt()
{
int out = 0xFFFFFFFF;
readBytes((char*)&out, sizeof(int));
if(mNetOrder)
{
out = SE_Util::net2HostInt32(out);
}
return out;
}
示例6: getMotion6
void getMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz)
{
readBytes(MPU6050Addr, MPU6050_RA_ACCEL_XOUT_H, 14, buffer);
*ax = (((int16_t)buffer[0]) << 8) | buffer[1];
*ay = (((int16_t)buffer[2]) << 8) | buffer[3];
*az = (((int16_t)buffer[4]) << 8) | buffer[5];
*gx = (((int16_t)buffer[8]) << 8) | buffer[9];
*gy = (((int16_t)buffer[10]) << 8) | buffer[11];
*gz = (((int16_t)buffer[12]) << 8) | buffer[13];
}
示例7: parseCorrupt
static uint64_t
parseCorrupt( tr_torrent * tor,
const uint8_t * buf,
uint32_t len )
{
if( len != sizeof( uint64_t ) )
return 0;
readBytes( &tor->corruptPrev, &buf, sizeof( uint64_t ) );
return TR_FR_CORRUPT;
}
示例8: readBytes
size_t DecompressPcm8Unsigned::getSamples(AudioSample * buffer,
size_t length) {
AudioByte *byteBuff =
reinterpret_cast<AudioByte *>(buffer);
size_t samplesRead = readBytes(byteBuff,length);
for(long i=samplesRead-1; i>=0; i--)
buffer[i] = static_cast<AudioSample>(byteBuff[i] ^ 0x80)
<< ((sizeof(AudioSample)-1)*8);
return samplesRead;
}
示例9: parseUploaded
static uint64_t
parseUploaded( tr_torrent * tor,
const uint8_t * buf,
uint32_t len )
{
if( len != sizeof( uint64_t ) )
return 0;
readBytes( &tor->uploadedPrev, &buf, sizeof( uint64_t ) );
return TR_FR_UPLOADED;
}
示例10: readBytes
int64_t AbstractTransport::readLong()
{
std::vector<char> longBytes= readBytes(8);
int64_t result = 0;
for (int i = 0; i < 8 ; i++) {
result <<= 8;
result ^= (int64_t) *(longBytes.data() + i) & 0xFF;
}
return result;
}
示例11: getRotation
/** Get 3-axis gyroscope readings.
* These gyroscope measurement registers, along with the accelerometer
* measurement registers, temperature measurement registers, and external sensor
* data registers, are composed of two sets of registers: an internal register
* set and a user-facing read register set.
* The data within the gyroscope sensors' internal register set is always
* updated at the Sample Rate. Meanwhile, the user-facing read register set
* duplicates the internal register set's data values whenever the serial
* interface is idle. This guarantees that a burst read of sensor registers will
* read measurements from the same sampling instant. Note that if burst reads
* are not used, the user is responsible for ensuring a set of single byte reads
* correspond to a single sampling instant by checking the Data Ready interrupt.
*
* Each 16-bit gyroscope measurement has a full scale defined in FS_SEL
* (Register 27). For each full scale setting, the gyroscopes' sensitivity per
* LSB in GYRO_xOUT is shown in the table below:
*
* <pre>
* FS_SEL | Full Scale Range | LSB Sensitivity
* -------+--------------------+----------------
* 0 | +/- 250 degrees/s | 131 LSB/deg/s
* 1 | +/- 500 degrees/s | 65.5 LSB/deg/s
* 2 | +/- 1000 degrees/s | 32.8 LSB/deg/s
* 3 | +/- 2000 degrees/s | 16.4 LSB/deg/s
* </pre>
*
* @param x 16-bit signed integer container for X-axis rotation
* @param y 16-bit signed integer container for Y-axis rotation
* @param z 16-bit signed integer container for Z-axis rotation
* @see getMotion6()
* @see MPU6050_RA_GYRO_XOUT_H
*/
PUBLIC void getRotation(int16* x, int16* y, int16* z) {
if(gyroEnabled)
{
readBytes(LSM6DS0_ADDRESS, OUT_X_L_G, 6, IMUBuffer);
*x = ((((int16)IMUBuffer[1]) << 8) | IMUBuffer[0]);
*y = ((((int16)IMUBuffer[3]) << 8) | IMUBuffer[2]);
*z = ((((int16)IMUBuffer[5]) << 8) | IMUBuffer[4]);
vWaitMicroseconds(500);
}
}
示例12: getEntryScript
void* getEntryScript()
{
fseek(HE1_File, RoomResource->RMDA->ENCD - 4, SEEK_SET);
uint32_t length;
readU32LE(HE1_File, &length);
length = SWAP_CONSTANT_32(length) - 8;
void* data = malloc(length);
readBytes(HE1_File, (uint8_t*)data, length);
return data;
}
示例13: parseConnections
static uint64_t
parseConnections( tr_torrent * tor,
const uint8_t * buf,
uint32_t len )
{
if( len != sizeof( uint16_t ) )
return 0;
readBytes( &tor->maxConnectedPeers, &buf, sizeof( uint16_t ) );
return TR_FR_MAX_PEERS;
}
示例14:
/*
* Read the control register
*/
byte DS1339::readControlRegister() {
byte ctrlReg = 0;
if(readBytes(&ctrlReg, DS1339_CONTROL_REG, 1) != 1) {
// Something went wrong so return -1
return 0xff;
}
return ctrlReg;
}
示例15: readBytes
DS::String DS::Stream::readString(size_t length, DS::StringType format)
{
String result;
if (format == e_StringUTF16) {
chr16_t* buffer = new chr16_t[length];
ssize_t bytes = readBytes(buffer, length * sizeof(chr16_t));
DS_DASSERT(bytes == static_cast<ssize_t>(length * sizeof(chr16_t)));
result = String::FromUtf16(buffer, length);
delete[] buffer;
} else {
chr8_t* buffer = new chr8_t[length];
ssize_t bytes = readBytes(buffer, length * sizeof(chr8_t));
DS_DASSERT(bytes == static_cast<ssize_t>(length * sizeof(chr8_t)));
result = (format == e_StringUTF8) ? String::FromUtf8(buffer, length)
: String::FromRaw(buffer, length);
delete[] buffer;
}
return result;
}