Exemplo n.º 1
0
static DWORD WINAPI pipeDataToSe(LPVOID pVClient) {
	char *buf = malloc(PIPE_BUF_SIZE);
	ClientElem_t *pClient = (ClientElem_t *)pVClient;
	while (pClient->running) {
		int nBytesRead = rbRead(&pClient->rbSoSe, buf, PIPE_BUF_SIZE, 1000);
		if (nBytesRead > 0) 
			DBG_PRINT("->SE got %i bytes from buf", nBytesRead);
		else 
			DBG_PRINT("->SE");
		if (nBytesRead < 0) {
			DBG_PRINT("ERROR uartrdbuf pipe");
			pClient->running = 0;
		} else if (nBytesRead > 0) {
			int wrIx = 0;
			int wrLen = 0;
			while (nBytesRead > 0 && wrLen >= 0 && pClient->running) {
				if (!writeSerial(pClient, (const char*)&buf[wrIx], nBytesRead, &wrLen, 1000)) {
					DBG_PRINT("ERROR uartwrite pipe %ld, hdl %ld", GetLastError(), pClient->serialHdl);
					pClient->running = 0;
				} else {
					wrIx += wrLen;
					nBytesRead -= wrLen;
				}
			}
		}
	}
	free(buf);
	DBG_PRINT("X->SE");
	return 0;
}
Exemplo n.º 2
0
//**************PUSH BUTTONS*********************//
void MainWindow::on_pushButton_stop_clicked()
{
    output.clear();
    output.append("SQ");
    writeSerial(output);

        ui->slider_throttle->setValue(0);
}
bool CloudWatcherController::sendCloudwatcherCommand(const char *command, int size) {
  int n = writeSerial(command, size);

  if (n != size) {
    return false;
  }

  return true;
}
Exemplo n.º 4
0
void MainWindow::on_pid_roll_d_2_valueChanged(double arg1)
{
    output.clear();

    output.append("SP1 3 ");             //1. Pitc 2. Roll 3. Yaw   //1. P 2. I 3.D
    output.append(QString::number((float)arg1));
    output.append("\r\n");

    writeSerial(output);
}
Exemplo n.º 5
0
void WriteThread::writeSerialSlot(struCseSensor *wstrBuf)
{
    CLOG::Log("writeDataToSerial .");

    ReadUart();

    if(writeFlag)
    {
        writeSerial(wstrBuf);
    }
}
Exemplo n.º 6
0
float edfa::EDFAReadPh2(){
    QString message;

    if(ready){
        writeSerial("Ph 2\r\n");
        message=readSerial();
        if (message.contains("PDM2: ",Qt::CaseInsensitive)){
            message = stripString(message, "PDM2:");
        }
    }

    return message.toFloat();
}
Exemplo n.º 7
0
void MainWindow::on_slider_pitch_valueChanged(int value)
{
    ui->lcd_pitch->display(value);

    output.clear();
    str.clear();

    output.append("SSP");
    output.append(str.setNum(double(value)));
    output.append("\r\n");

    writeSerial(output);

}
Exemplo n.º 8
0
void MainWindow::on_slider_throttle_valueChanged(int value)
{
    ui->lcd_throttle->display(value);

    output.clear();
    str.clear();

    output.append("SST");
    output.append(str.setNum(int(value)));
    output.append("\r\n");

    writeSerial(output);

}
Exemplo n.º 9
0
void initiateParse(void){
  if(rxn == 0 || rxn == 1){
  }
  else if(1 <= rxn && rxn < MAXBUFFERSIZE){
    int size = (rx[1] << 8) | (rx[2] << 0);
    if(rxn == size+4){
      parse();
      int i = 0;
      for(; i < size+4+1; i++) //DEBUG
        rx[i] = 0x00;
      rxn = 0;
    }
    else{
      int i = 0;
      for(;i<size+4;i++)
		writeSerial(rx[i]);
      writeSerial('\n');
    }
  }
  else{
    writeSerial(0xFF);
  }
  rxn = (rxn + 1) % MAXBUFFERSIZE;
}
Exemplo n.º 10
0
bool edfa::getEmission(){
    bool emission = false; //This needs to be made better so that the method will return something if no emission is found.
    QString message;

    if(ready){
        writeSerial("OM\r\n");
        message = readSerial();
        qDebug() << "get EDFA emission message " << message;
        if (message.contains("OM ",Qt::CaseInsensitive)){
            message = stripString(message, "OM");
            qDebug() << "message contains OM";
            qDebug() << "New message " << message;
        }
    }
    if(message == "O"){
        emission = false;
    }
    if(message == "2"){
        emission = true;
    }

return emission;
}
Exemplo n.º 11
0
void MainWindow::on_pushButton_enable_pid_settings_clicked()
{
     writeSerial("SE"); //MOTOR TEST
}
Exemplo n.º 12
0
void CMonitor::TestSendMsg()
{

    m_bConnected2 = true;

    struCseSensor seSerial;
    memset(&seSerial, 0, sizeof(struCseSensor));

    seSerial.acc = 1;
    seSerial.bck = 2;
    seSerial.env_hdy = 3;
    seSerial.env_hdy_val = 4;
    seSerial.env_tmp = 5;
    seSerial.env_tmp_val = 6;
    seSerial.fil = 7;
    seSerial.fil_val = 8;
    seSerial.fld = 9;
    seSerial.inf =10;
    seSerial.lcd =11;
    seSerial.lcd_val =12;
    seSerial.lcd_tmp =13;
    seSerial.lcd_tmp_val =14;
    seSerial.scr =15;
    seSerial.shk =16;
    seSerial.smk =17;
    seSerial.fan_speed01 =18;
    seSerial.fan_speed02 =19;
    seSerial.fan_speed03 =20;
    seSerial.fan_speed04 =21;
    seSerial.fan_speed05 =22;
    seSerial.fan_speed06 =23;
    seSerial.fan_speed07 =24;
    seSerial.fan_speed08 =25;
    seSerial.fan_speed09 =26;
    seSerial.fan_speed10 =27;
    seSerial.fan_speed11 =28;
    seSerial.fan_speed12 =29;
    seSerial.fan_speed13 =30;
    seSerial.fan_speed14 =31;
    seSerial.fan_speed15 =32;
    seSerial.fan_speed16 =33;
    seSerial.status =1;


    //向与安卓设备通信串口发信号
      //TestSendMsg ();
    struCseSensor wSerial;
    memset(&wSerial, 0, sizeof(struCseSensor));
    memcpy(&wSerial, &seSerial, sizeof(struCseSensor));

    emit writeSerial(&seSerial);



    QString strLog = QString( "%1,%2")
            .arg(seSerial.acc).arg(seSerial.bck);
    CLOG::Log(strLog.toLatin1().data());
    // send sensor to monitor center
    if(true == m_bConnected2)
    {
        // cse msg
        struCseMsg seMsg;
        memset(&seMsg, 0, sizeof(struCseMsg));

        seMsg.msg_id = CSE_SENSOR_REQ_MESSAGE;
        qDebug()<<"seMsg.msg_id="<< seMsg.msg_id;
        seMsg.msg_len = sizeof(struCseSensor);
        strcpy(seMsg.prd_id, m_cfgFile.m_strPrdID.toLatin1().data());
        qDebug()<<"**seMsg.prd_id="<< seMsg.prd_id;
        memcpy(seMsg.msg, &seSerial, seMsg.msg_len);

        // send msg
        QByteArray msg;
        msg.resize(sizeof(struCseMsg));
        memcpy(msg.data(), &seMsg, sizeof(struCseMsg));

        // m_bSend2=m_pTcpClient2->SendToServer(msg.data(), sizeof(struCseMsg));


        CLOG::Log(msg.data());

        qDebug()<<"send acc="<<seSerial.acc;
        qDebug()<<"send bck="<<seSerial.bck;
        qDebug()<<"send env_hdy="<<seSerial.env_hdy;
        qDebug()<<"send env_hdy_val="<< seSerial.env_hdy_val;
        qDebug()<<"send env_tmp="<< seSerial.env_tmp;
        qDebug()<<"send env_tmp_val="<<seSerial.env_tmp_val;
        qDebug()<<"send fil="<<seSerial.fil;
        qDebug()<<"send fil_val="<<seSerial.fil_val;
        qDebug()<<"send fld="<< seSerial.fld;
        qDebug()<<"send inf="<<seSerial.inf;
        qDebug()<<"send lcd="<<seSerial.lcd;
        qDebug()<<"send lcd_val="<<seSerial.lcd_val;
        qDebug()<<"send lcd_tmp="<<seSerial.lcd_tmp;
        qDebug()<<"send lcd_tmp_val="<<seSerial.lcd_tmp_val;
        qDebug()<<"send src="<<seSerial.scr;
        qDebug()<<"send shk="<<seSerial.shk;
        qDebug()<<"send smk="<<seSerial.smk;

    }
}
Exemplo n.º 13
0
void MainWindow::on_pushButton_start_clicked()
{
    writeSerial("SA");
}
Exemplo n.º 14
0
void MainWindow::on_pushButton_get_set_points_clicked()
{
    writeSerial("GA");
}
Exemplo n.º 15
0
void MainWindow::on_pushButton_calibrate_clicked()
{
    writeSerial("SC");
}
Exemplo n.º 16
0
void MainWindow::on_checkBox_motors_clicked()
{
    writeSerial("GM");
}//-------------------------------------------//
Exemplo n.º 17
0
void MainWindow::on_pushButton_get_euler_clicked()
{
    writeSerial("SS");
}
Exemplo n.º 18
0
void MainWindow::on_pushButton_reset_altitude_clicked()
{
    writeSerial("SR");
}
Exemplo n.º 19
0
void MainWindow::on_pushButton_test_clicked()
{
    writeSerial("SM"); //MOTOR TEST
}
Exemplo n.º 20
0
void MainWindow::on_pushButton_get_loop_time_clicked()
{
    writeSerial("GT");
}
Exemplo n.º 21
0
void MainWindow::on_pushButton_get_raw_values_clicked()
{
    writeSerial("GR");
}