本文整理汇总了C++中writePacket函数的典型用法代码示例。如果您正苦于以下问题:C++ writePacket函数的具体用法?C++ writePacket怎么用?C++ writePacket使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writePacket函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: brl_construct
static int
brl_construct (BrailleDisplay *brl, char **parameters, const char *device) {
if (!isSerialDevice(&device)) {
unsupportedDevice(device);
return 0;
}
if ((serialDevice = serialOpenDevice(device))) {
if (serialRestartDevice(serialDevice, serialBaud)) {
static const unsigned char request[] = {BNO_DESCRIBE};
charactersPerSecond = serialBaud / 10;
if (writePacket(brl, request, sizeof(request)) != -1) {
while (serialAwaitInput(serialDevice, 100)) {
ResponsePacket response;
int size = getPacket(&response);
if (size) {
if (response.data.code == BNI_DESCRIBE) {
statusCells = response.data.values.description.statusCells;
brl->textColumns = response.data.values.description.textCells;
brl->textRows = 1;
brl->keyBindings = "keys";
if ((statusCells == 5) && (brl->textColumns == 30)) {
statusCells -= 2;
brl->textColumns += 2;
}
dataCells = brl->textColumns * brl->textRows;
cellCount = statusCells + dataCells;
makeOutputTable(dotsTable_ISO11548_1);
makeInputTable();
if ((cellBuffer = malloc(cellCount))) {
memset(cellBuffer, 0, cellCount);
statusArea = cellBuffer;
dataArea = statusArea + statusCells;
refreshCells(brl);
persistentKeyboardMode = KBM_NAVIGATE;
temporaryKeyboardMode = persistentKeyboardMode;
persistentRoutingOperation = BRL_BLK_ROUTE;
temporaryRoutingOperation = persistentRoutingOperation;
return 1;
} else {
logSystemError("cell buffer allocation");
}
} else {
logUnexpectedPacket(response.bytes, size);
}
}
}
}
}
serialCloseDevice(serialDevice);
serialDevice = NULL;
}
return 0;
}
示例2: writePacket
void Driver::cleanComChannel()
{
try
{
writePacket(reinterpret_cast<uint8_t const*>("\r"), 1, 100);
readConfigurationAck();
}
catch (std::runtime_error e) {}
}
示例3: writePacket
bool SeaNet::isFullDuplex(int timeout)
{
std::vector<uint8_t> packet = SeaNetPacket::createPaket(device_type,mtSendBBUser);
writePacket(&packet[0],packet.size());
waitForPacket(mtBBUserData,timeout);
BBUserData settings;
sea_net_packet.decodeBBUserData(settings);
return settings.full_duplex;
}
示例4: DebugPacketBpHit
void
DebugNet::writeBreakpointHit(uint32_t coreId, uint32_t userData)
{
auto pak = new DebugPacketBpHit();
pak->coreId = coreId;
pak->userData = userData;
populateDebugPauseInfo(pak->info);
writePacket(pak);
}
示例5: loopTruthTable
static void
loopTruthTable(TruthTable truthset[])
{
for(int i = 0; truthset[i].packet != NULL; i++)
{
writePacket(&truthset[i]);
}
}
示例6: secPack
void secPack(int fd, void *secpack) {
LOG(LOGLEVEL_INFO, "Sending secpack...\n");
writePacket(fd, 0x204, secpack, 0x800);
char buffer[PACKET_SIZE(SECPACK_REPLY_PACKET_SIZE)];
size_t rlength = readPacket(fd, WRITE_TIMEOUT, buffer, sizeof(buffer));
SecpackReplyPacket *reply = verifyPacket(buffer, rlength);
LOG(LOGLEVEL_DEBUG, "Secpack returns: unknown1=%d unknown2=0x%x\n", reply ? reply->unknown1 : 0, reply ? reply->unknown2 : 0);
}
示例7: seekBaseband
void seekBaseband(int fd, unsigned int offset) {
LOG(LOGLEVEL_INFO, "Seeking to 0x%08x...\n", offset);
writePacket(fd, 0x802, &offset, sizeof(offset));
char buffer[PACKET_SIZE(SEEK_REPLY_PACKET_SIZE)];
size_t length = readPacket(fd, DEFAULT_TIMEOUT, buffer, sizeof(buffer));
LOG(LOGLEVEL_DEBUG, "Seek returns:\n");
LOGDO(LOGLEVEL_DEBUG, printBuffer(verifyPacket(buffer, length), SEEK_REPLY_PACKET_SIZE));
}
示例8: resume
void resume()
{
assert(paused);
paused = false;
ZhttpResponsePacket p;
p.type = ZhttpResponsePacket::KeepAlive;
writePacket(p);
}
示例9: writePacket
// Send a Midi PROGRAM CHANGE message to given channel, with program ID 0-127
void USBMidi::sendProgramChange(unsigned int channel, unsigned int program)
{
outPacket.p.cable=DEFAULT_MIDI_CABLE;
outPacket.p.cin=CIN_PROGRAM_CHANGE;
outPacket.p.midi0=MIDIv1_PROGRAM_CHANGE |(channel & 0x0f);
outPacket.p.midi1=program;
writePacket(outPacket.i);
}
示例10: readPacket
// Returns a packet read from the serial connection
ARCPOPacket& readPacket(ARCPOPacket& pPacket) {
char vReadChar;
boolean vStarterRead = false;
mPacketRead = false;
if (Serial.available() > 0) {
//wait to make sure everything will be there
//at 9600 bps, one need (1/9600) * 8 bits * 64 byte = 0.053 sec. We wait 0.1 sec to be sure.
delay(100);
while(Serial.available() > 0) {
vReadChar = Serial.read();
//search the start
if (vReadChar == '$') {
vStarterRead = true;
}
else {
//confirm the start
if (vStarterRead && vReadChar == '*') {
vStarterRead = false;
pPacket = readPacketInternal(pPacket);
mPacketRead = true;
}
else {
//crap in the buffer, clean until next starter or empty
vStarterRead = false;
}
}
}
}
#ifdef ARCPO_Lib_DEBUGMODE
else {
Serial.print ("DBG: readPacket : no data => ");
Serial.println ((int)Serial.available());
}
#endif
if (mPacketRead && pPacket.ExpectAcknowledge == 1) {
#ifdef ARCPO_Lib_DEBUGMODE
Serial.print ("Acknowledgement -->");
#endif
//acknowledge packet
ARCPOPacket vPacketAck;
vPacketAck.ID = pPacket.ID;
vPacketAck.Type = 255;
vPacketAck.SubType = 255;
vPacketAck.ExpectAcknowledge = 255;
vPacketAck.Content[0] = 'A';
vPacketAck.Content[1] = 'C';
vPacketAck.Content[2] = 'K';
vPacketAck.Content[3] = 0;
writePacket(vPacketAck);
}
return pPacket;
}
示例11: pause
void pause()
{
assert(!doReq);
pausing = true;
ZhttpResponsePacket p;
p.type = ZhttpResponsePacket::HandoffStart;
writePacket(p);
}
示例12: ackPacket
/*
* Acknowledge a received packet
*/
static void ackPacket(uint8_t ack /* ack return value */
)
{
gPacket.data[PACKET_DESTINATION] = gPacket.data[PACKET_SOURCE];
gPacket.data[PACKET_SOURCE] = gPacket.myAddr;
gPacket.data[PACKET_COMMAND] = ack;
gPacket.length = 6;
writePacket();
}
示例13: writeLocation
static int
writeLocation (BrailleDisplay *brl) {
unsigned char packet[2];
unsigned char *byte = packet;
*byte++ = statusCells[gscScreenCursorRow];
*byte++ = statusCells[gscScreenCursorColumn];
return writePacket(brl, packet, byte-packet);
}
示例14: respond
void respond()
{
state = Connected;
ZhttpResponsePacket out;
out.code = responseCode;
out.reason = responseReason;
out.headers = responseHeaders;
writePacket(out);
}
示例15: endSecPack
void endSecPack(int fd) {
LOG(LOGLEVEL_INFO, "Ending secpack...\n");
unsigned short unknown = 0;
writePacket(fd, 0x205, &unknown, sizeof(unknown));
char buffer[PACKET_SIZE(sizeof(unsigned short))];
size_t rlength = readPacket(fd, DEFAULT_TIMEOUT, buffer, sizeof(buffer));
unsigned short *ret = verifyPacket(buffer, rlength);
LOG(LOGLEVEL_DEBUG, "End secpack returns: %d\n", ret ? *ret : 0);
}