本文整理汇总了C++中sio_write函数的典型用法代码示例。如果您正苦于以下问题:C++ sio_write函数的具体用法?C++ sio_write怎么用?C++ sio_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sio_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sio_write
/***************************************************************
【函数功能】: 使能惯导模块的数据输出
【输 入】: bEnable:True使能输出;False失能输出
【输 出】: 执行结果:0正确;-1错误
【说 明】: !经过实验验证!
***************************************************************/
int CGyro::Enable(bool bEnable)
{
char eBuf[18] = {'@','*',1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, -2,'*'};
char dBuf[18] = {'@','*',1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, -1,'*'};
if(!m_bPortOpened)
return -1;
//if (bEnable^m_bOutEnabled) // 0,1或1,0才输出。不同才操作
{
if (bEnable)
{
sio_write(m_iPort, eBuf, 18);
sleep(10);
sio_write(m_iPort, eBuf, 18);
m_bOutEnabled = true;
}
else
{
sio_write(m_iPort, dBuf, 18);
sleep(10);
sio_write(m_iPort, dBuf, 18);
m_bOutEnabled = false;
}
}
return 0;
}
示例2: sndio_proc
static ALuint sndio_proc(ALvoid *ptr)
{
ALCdevice *device = ptr;
sndio_data *data = device->ExtraData;
ALsizei frameSize;
size_t wrote;
SetRTPriority();
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
while(!data->killNow && device->Connected)
{
ALsizei len = data->data_size;
ALubyte *WritePtr = data->mix_data;
aluMixData(device, WritePtr, len/frameSize);
while(len > 0 && !data->killNow)
{
wrote = sio_write(data->sndHandle, WritePtr, len);
if(wrote == 0)
{
ERR("sio_write failed\n");
aluHandleDisconnect(device);
break;
}
len -= wrote;
WritePtr += wrote;
}
}
return 0;
}
示例3: fluid_sndio_audio_run2
/*
* fluid_sndio_audio_run
*/
void*
fluid_sndio_audio_run2(void* d)
{
fluid_sndio_audio_driver_t* dev = (fluid_sndio_audio_driver_t*) d;
short* buffer = (short*) dev->buffer;
float* left = dev->buffers[0];
float* right = dev->buffers[1];
int buffer_size = dev->buffer_size;
int dither_index = 0;
FLUID_LOG(FLUID_DBG, "Audio thread running");
/* it's as simple as that: */
while (dev->cont)
{
(*dev->callback)(dev->data, buffer_size, 0, NULL, 2, dev->buffers);
fluid_synth_dither_s16 (&dither_index, buffer_size, left, right,
buffer, 0, 2, buffer, 1, 2);
sio_write (dev->hdl, buffer, dev->buffer_byte_size);
}
FLUID_LOG(FLUID_DBG, "Audio thread finished");
pthread_exit(NULL);
return 0; /* not reached */
}
示例4: WriteData
//---------------------------------------------------------------------------
bool __fastcall CSerialPort::WriteData(char *pBuffer)
{
if(sio_write(m_nPortNo,pBuffer,strlen(pBuffer))<0)
return false;
return true;
}
示例5: wbsio_get_spibase
static uint16_t wbsio_get_spibase(uint16_t port)
{
uint8_t id;
uint16_t flashport = 0;
w836xx_ext_enter(port);
id = sio_read(port, 0x20);
if (id != 0xa0) {
msg_perr("\nW83627 not found at 0x%x, id=0x%02x want=0xa0.\n", port, id);
goto done;
}
if (0 == (sio_read(port, 0x24) & 2)) {
msg_perr("\nW83627 found at 0x%x, but SPI pins are not enabled. (CR[0x24] bit 1=0)\n", port);
goto done;
}
sio_write(port, 0x07, 0x06);
if (0 == (sio_read(port, 0x30) & 1)) {
msg_perr("\nW83627 found at 0x%x, but SPI is not enabled. (LDN6[0x30] bit 0=0)\n", port);
goto done;
}
flashport = (sio_read(port, 0x62) << 8) | sio_read(port, 0x63);
done:
w836xx_ext_leave(port);
return flashport;
}
示例6: sndio_update
/* write as many blocks as is currently possible */
static void
sndio_update(int threaded)
{
struct pollfd pfd;
nfds_t nfds;
int i, nblocks, nbytes;
/* make sure counters have been updated */
nfds = sio_pollfd(hdl, &pfd, POLLOUT);
poll(&pfd, nfds, 0);
if (!(sio_revents(hdl, &pfd) & POLLOUT))
return;
nblocks = (sndio_play_appbufsz - (sndio_playpos - sndio_realpos)) /
sndio_play_round;
/* we got POLLOUT, so we can write something. if we don't
* write anything, we could underrun.
*/
if (nblocks < 1)
nblocks = 1;
for (i = 0; i < nblocks; i++) {
sio_write(hdl, sndio_play_bufdata, sndio_play_bufsize);
sndio_playpos += sndio_play_round;
if (sio_eof(hdl)) {
/* print error message? */
return;
}
_mix_some_samples((uintptr_t) sndio_play_bufdata, 0, sndio_signed);
}
}
示例7: ppp_output_cb
static u32_t
ppp_output_cb(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx)
{
LWIP_UNUSED_ARG(pcb);
LWIP_UNUSED_ARG(ctx);
return sio_write(ppp_sio, data, len);
}
示例8: channels
void AudioSndio::run( void )
{
surroundSampleFrame * temp =
new surroundSampleFrame[mixer()->framesPerPeriod()];
int_sample_t * outbuf =
new int_sample_t[mixer()->framesPerPeriod() * channels()];
while( TRUE )
{
const fpp_t frames = getNextBuffer( temp );
if( !frames )
{
break;
}
uint bytes = convertToS16( temp, frames,
mixer()->masterGain(), outbuf, FALSE );
if( sio_write( m_hdl, outbuf, bytes ) != bytes )
{
break;
}
}
delete[] temp;
delete[] outbuf;
}
示例9: try_write
static gboolean
try_write (Stream *stream)
{
#define STEP 1024
int avail, step, rendered, written, bpf;
gboolean finish = FALSE;
avail = swfdec_playback_stream_avail_update (stream);
bpf = stream->par.bps * stream->par.pchan;
while (avail > 0 && !finish) {
gint16 data[2 * STEP];
step = MIN (avail, STEP);
rendered = swfdec_audio_render (stream->audio, data, stream->offset, step);
if (rendered < step) {
finish = TRUE;
}
written = sio_write (stream->hdl, data, rendered * bpf) / bpf;
avail -= written;
stream->offset += rendered;
stream->f_written += written;
}
if (finish) {
swfdec_playback_stream_remove_handlers (stream);
}
return TRUE;
#undef STEP
}
示例10: WaitForSingleObject
/***************************************************************
【函数功能】: 发送Set报文
【输 入】: 无
【输 出】: 执行结果:0正确;-1错误;-2发送报文失败;
【说 明】: 在timer中第6发送时刻被调用。直接通过串口发送。
***************************************************************/
int CSensor::SendSetFrame()
{
if(!m_bPortOpened)
return -1;
if (m_pSendQueue->QueueNData() < 10)
{
m_pSendQueue->QueueFlush();
return -1;
}
char buf[10];
m_pSendQueue->QueueNRead(buf, 10);
if (((BYTE)buf[0] != 0xAA) || ((BYTE)buf[1] != 0x55))
{
return -1;
}
/**********************************************/
WaitForSingleObject(m_hMutex,1000);
// 占用串口发送资源
m_sCmd.send = (BYTE)buf[3];
m_sCmd.stat = STAT_SENSOR_T2T;
m_sCmd.addr = (BYTE)buf[4];
m_sCmd.ack = CMD_IO_ACK;
// 直接通过串口发送,保证时间精度
int err = sio_write(m_iPort, buf, 10); // 持续时间大约10us
m_sCmd.stat = STAT_SENSOR_T2R;
ReleaseMutex(m_hMutex);
/**********************************************/
if (err != 10)
return -2;
return 0;
}
示例11: BlockingWriteStream
static PaError
BlockingWriteStream(PaStream* stream, const void *data, unsigned long numFrames)
{
PaSndioStream *s = (PaSndioStream *)stream;
unsigned n, res;
while (numFrames > 0) {
n = s->par.round;
if (n > numFrames)
n = numFrames;
PaUtil_SetOutputFrameCount(&s->bufproc, n);
PaUtil_SetInterleavedOutputChannels(&s->bufproc, 0, s->wbuf, s->par.pchan);
res = PaUtil_CopyOutput(&s->bufproc, &data, n);
if (res != n) {
DPR("BlockingWriteStream: copyOutput: %u != %u\n");
return paUnanticipatedHostError;
}
res = sio_write(s->hdl, s->wbuf, n * s->par.pchan * s->par.bps);
if (res == 0)
return paUnanticipatedHostError;
s->wpos += n;
numFrames -= n;
}
return paNoError;
}
示例12: bufdump
static void
bufdump (struct xmp_context *ctx, int len)
{
void *buf;
if ((buf = xmp_smix_buffer (ctx)) != NULL)
sio_write (hdl, buf, len);
}
示例13: output_data
static int output_data(char *buf, int32 nbytes)
{
if (!sio_write(sndio_ctx, buf, nbytes)) {
ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, "sio_write() failed");
return -1;
}
return 0;
}
示例14: sndio_write
static int sndio_write(const char *buf, int cnt)
{
size_t rc;
rc = sio_write(hdl, buf, cnt);
if (rc == 0)
return -OP_ERROR_INTERNAL;
return rc;
}
示例15: switch
/***************************************************************
【函数功能】: 输入校正坐标数据
【输 入】: iFlag:校正哪个数据;fValue:数据值
【输 出】: 执行结果:0正确;-1错误。
【说 明】: !经过实验验证! 角度信息的单位必须是弧度
***************************************************************/
int CGyro::Reset(int iFlag, double fValue)
{
if(!m_bPortOpened)
return -1;
UGyroFrame uFrame = {0};
uFrame.st.head[0] = '@';
uFrame.st.head[1] = '*';
uFrame.st.cmd[0] = -1;
if (iFlag > 7)
{
//AfxMessageBox("惯导:复位数据的flag错误!");
return -1;
}
switch (iFlag)
{
case GYRO_RST_POSX:
uFrame.st.posx = fValue;
break;
case GYRO_RST_POSY:
uFrame.st.posy = fValue;
break;
case GYRO_RST_ANGLE:
fValue -= M_PI/2.0f;
while (fValue > MAX_GYRO_ANGLE)
{
fValue -= 2*M_PI;
}
while(fValue <= MIN_GYRO_ANGLE)
{
fValue += 2*M_PI;
}
fValue = fValue * (-1.0f); // 还原成顺正逆负
if (fValue < 0)
{
fValue += 2*M_PI;
}
uFrame.st.angle = fValue;
break;
default:
//AfxMessageBox("惯导:复位数据的flag错误!");
return -1;
}
uFrame.st.cmd[1] = (BYTE)iFlag;
char sum = 0;
for (int i=0; i<14; i++)
{
sum += uFrame.buf[2+i];
}
uFrame.st.checksum = (BYTE)(-sum);
uFrame.st.tail = '*';
sio_write(m_iPort,uFrame.buf, 18);
return 0;
}