本文整理汇总了C++中sendChar函数的典型用法代码示例。如果您正苦于以下问题:C++ sendChar函数的具体用法?C++ sendChar怎么用?C++ sendChar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendChar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_ctc
int parse_ctc(char s[])
{
char ctc[11];
unsigned char i = 3, j = 0;
while( (s[i] != '\0') && (j <= 11) )
{
if( (s[i] >= '0') && (s[i] <= '9') )
{
ctc[j++] = s[i++];
}
else
{
sendFString(ERROR_NONINT);
sendChar(s[i]);
sendChar('\r');
return 0;
}
}
ctc[j] = '\0';
if(j>4)// must be < 256
{
sendFString(ERROR_NUMTOLARGE);
return 0;
}
else
{
set_ctc(atoi(ctc));
}
return 1;
}
示例2: sendString
bool InterfaceAvr::sendString(QString string, QString callingClassName)
{
// QString debugstring;
// emit message(">>> sendString");
// send starter
if (sendChar(starter, callingClassName) == true)
{
// send 'content' of string
// debugstring = "*";
for (int i=0; i<string.length(); i++)
{
// char by char
if (sendChar(string.at(i).toAscii(), callingClassName) == false)
{
return false;
}
// debugstring.append(string.at(i));
}
// send terminator
if (sendChar(terminator, callingClassName) == true)
{
// success
// debugstring.append("#");
// emit message(debugstring);
return true;
}
}
return false;
}
示例3: header
//======================================================================
// Get a header record. If its not an empty one, open the output
// file.
//======================================================================
static int
header(SerialPort& port)
{
// Get a header sector (sector 0)
sendChar(port, NAK);
int block = getBlock(port, blockBuf);
if (block == ERROR)
return ERROR;
if (block != 0) {
exitCode = 3;
return ERROR;
}
sendChar(port, ACK);
// If its a empty header, just return
if (blockBuf[0] == 0)
return OK;
// Get the number of bytes in the file
bytesLeft = 2000000000L;
char* ptr = blockBuf + 1 + strlen(blockBuf);
if (*ptr)
sscanf(ptr, "%ld", &bytesLeft);
// Try to open the filename
outputFile = fopen(blockBuf, "w");
if (outputFile == NULL) {
exitCode = 4;
return ERROR;
}
printf("Receiving %s (%ld)\n", blockBuf, bytesLeft);
return OK;
}
示例4: stmSendTrajectory
/* -------------------------------------------------------------------- */
void stmSendTrajectory(float elevatorTrajectory[5], float aileronTrajectory[5]) {
char crc = 0;
sendChar(usart_buffer_stm, 'a', &crc); // this character initiates the transmission
sendChar(usart_buffer_stm, 1 + 5*4 + 5*4, &crc); // this will be the size of the message
sendChar(usart_buffer_stm, 't', &crc); // id of the message
int i;
// send the elevator trajectory
for (i = 0; i < 5; i++) {
sendFloat(usart_buffer_stm, elevatorTrajectory[i], &crc);
}
// send the aileron trajectory
for (i = 0; i < 5; i++) {
sendFloat(usart_buffer_stm, aileronTrajectory[i], &crc);
}
// at last send the crc, ends the transmission
sendChar(usart_buffer_stm, crc, &crc);
}
示例5: sendChar
void TxUART::sendNumber(unsigned int sendMe){
sendChar(((sendMe / 10000)%10)+48);
sendChar(((sendMe / 1000)%10)+48);
sendChar(((sendMe / 100)%10)+48);
sendChar(((sendMe / 10)%10)+48);
sendChar(((sendMe)%10)+48);
}
示例6: muckle_over
void muckle_over(int awardQP) {
CharData *i;
int reward = 0;
for(i = character_list; i; i = i->next) {
sendChar(i, "The quest is over.\r\n");
REMOVE_BIT_AR(PRF_FLAGS(i), PRF_QUEST);
if(!awardQP)
break;
reward = i->muckleTime/60 + (i->muckleTime % 60 > 0 ? 1:0);
if(i->muckleTime == muckle_duration * 60)
reward += 2;
if(!IS_NPC(i) && reward) {
sendChar(i, "You have been awarded %d quest points for your effort.\r\n", reward);
GET_QP(i) += reward;
mudlog(BRF, LVL_IMMORT, TRUE, "%s has received %d quest points for %s efforts in muckle.",
GET_NAME(i), reward, HSHR(i));
}
i->muckleTime = 0;
}
CONFIG_QUEST_ACTIVE = 0;
}
示例7: ansi_me
void ansi_me(void)
{
// ANSI turn off all attribute: me=\E[0m
sendChar(27);
sendChar('[');
sendChar('0');
sendChar('m');
}
示例8: sendChar
void TiBasicEditor::sendKey(SDL_keysym k1)
{
SDLKey k=k1.sym;
if (keyParser::isChar(k1))
{
sendChar(keyParser::getChar(k1));
return;
}
if (_isInSpecialCommandsMenu)
{
switch (k)
{
case SDLK_RETURN:
sendChar( _specialsCommandsMenu->getSelectedString()[0]);
_isInSpecialCommandsMenu=false;
reDisplay();
return;
case SDLK_DELETE:
_isInSpecialCommandsMenu=false;
reDisplay();
return;
default:
_specialsCommandsMenu->sendKey(k1);
}
}
else
{
switch (k)
{
case SDLK_DELETE:
rmChar();
break;
case SDLK_UP:
changeLine(true);
break;
case SDLK_DOWN:
changeLine(false);
break;
case SDLK_LEFT:
changeCursorPos(true);
break;
case SDLK_RIGHT:
changeCursorPos(false);
break;
case SDLK_RETURN:
addLine();
break;
case SDLK_LALT:
_isInSpecialCommandsMenu=true;
_specialsCommandsMenu->reDisplay();
break;
}
}
}
示例9: menu
void menu ( void )
{
sendChar ( '\r' );
sendString ( "Menu\r" );
sendString ( "a. Add\r" );
sendString ( "b. Sub\r" );
sendString ( "c. Mult\r" );
sendString ( "d. Integer division\r" );
sendString ( "e. Decimal division\r" );
sendChar ( '\r' );
}
示例10: getBlock
//======================================================================
// Get a whole block. Handles checksums, ...
//======================================================================
static int
getBlock(SerialPort& port, char* block)
{
int checksum;
int ch;
int blockNum;
for (int errorCnt = 0; errorCnt < RETRY_MAX; errorCnt++) {
ch = recvChar(port, 2);
if (ch == EOT) {
sendChar(port, ACK);
return GOT_EOT;
}
if (ch == CAN) {
exitCode = 7;
return ERROR;
}
if (ch == SOH || ch == STX) {
if (ch == SOH)
blockLen = 128;
else
blockLen = 1024;
blockNum = recvChar(port, 2);
ch = recvChar(port, 2);
if (blockNum + ch == 0377) {
checksum = 0;
char* p = block;
for (int cnt = 0; cnt < blockLen; cnt++) {
ch = recvChar(port, 2);
checksum += (*p++ = ch);
}
ch = recvChar(port, 2);
if (((checksum - ch) & 0377) == 0)
return blockNum;
exitCode = 8;
}
}
if (ch == TIMEOUT)
exitCode = 9;
flushInput(port);
sendChar(port, NAK);
}
return ERROR;
}
示例11: stmSetKalmanPosition
/* -------------------------------------------------------------------- */
void stmSetKalmanPosition(float elevatorPos, float aileronPos) {
char crc = 0;
sendChar(usart_buffer_stm, 'a', &crc); // this character initiates the transmission
sendChar(usart_buffer_stm, 1 + 2*4, &crc); // this will be the size of the message
sendChar(usart_buffer_stm, '3', &crc); // id of the message
sendFloat(usart_buffer_stm, elevatorPos, &crc);
sendFloat(usart_buffer_stm, aileronPos, &crc);
// at last send the crc, ends the transmission
sendChar(usart_buffer_stm, crc, &crc);
}
示例12: stmResetKalman
/* -------------------------------------------------------------------- */
void stmResetKalman(float initElevator, float initAileron) {
char crc = 0;
sendChar(usart_buffer_stm, 'a', &crc); // this character initiates the transmission
sendChar(usart_buffer_stm, 1 + 2*4, &crc); // this will be the size of the message
sendChar(usart_buffer_stm, '2', &crc); // id of the message
sendFloat(usart_buffer_stm, initElevator, &crc);
sendFloat(usart_buffer_stm, initAileron, &crc);
// at last send the crc, ends the transmission
sendChar(usart_buffer_stm, crc, &crc);
}
示例13: sendChar
void LCD1602::sendString (const char str[])
{
uint8_t i;
for(i = 0; str[i] != '\0'; i++)
sendChar(str[i]);
}
示例14: sendString
void sendString(char* string, u8 len)
{
u8 i;
for (i=0;i<len;i++)
sendChar(string[i]);
}
示例15: stmSendSetpoint
/* -------------------------------------------------------------------- */
void stmSendSetpoint(float elevatorSetpoint, float aileronSetpoint) {
char crc = 0;
sendChar(usart_buffer_stm, 'a', &crc); // this character initiates the transmission
sendChar(usart_buffer_stm, 1 + 2*4, &crc); // this will be the size of the message
sendChar(usart_buffer_stm, 's', &crc); // id of the message
// sends the payload
sendFloat(usart_buffer_stm, elevatorSetpoint, &crc);
sendFloat(usart_buffer_stm, aileronSetpoint, &crc);
// at last send the crc, ends the transmission
sendChar(usart_buffer_stm, crc, &crc);
}