本文整理汇总了C++中Serial::InitSerial方法的典型用法代码示例。如果您正苦于以下问题:C++ Serial::InitSerial方法的具体用法?C++ Serial::InitSerial怎么用?C++ Serial::InitSerial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Serial
的用法示例。
在下文中一共展示了Serial::InitSerial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int /*argc*/, char** /*argv*/)
{
char panval[BUFFERSIZE];
char tiltval[BUFFERSIZE];
char distance[BUFFERSIZE];
char* str = (char*)malloc(sizeof(char)*BUFFERSIZE);
/*char* panval;
panval = "ron01\r\n";
char* tiltval;
tiltval = "ron01\r\n";
char* distance;
distance = "ron01\r\n";*/
char* camwait;
camwait = "end00\r\n";
char* startstr;
startstr = "frame\r\n";
cv::Mat mat;
cv::Mat mat2;
cv::Point target;
Serial serial;
long long start;
long long elapsed;
//char* str;
//str = "ron01\r\n";
if (!serial.InitSerial("COM3", 115200)) {
return 0;
}
if (!pgrey.InitSingleCamera())
{
return 0;
}
FlyCapture2::Error error = pgrey.cam.StartCapture(OnImageGrabbed);
if (error != PGRERROR_OK)
{
cout << "start capture failed" << endl;
return 0;
}
for (;;)
{
//start = milliseconds_now();
if (status == 0) {
if (serial.Read(&str)) {
if (*str == *camwait) {
//status = 1;
}
else if (str[0] == 'P') {
strncpy(panval, str, sizeof(str));
}
else if (str[0] == 'T') {
strncpy(tiltval, str, sizeof(str));
}
else if (str[0] == 'D') {
strncpy(distance, str, sizeof(str));
}
else if (*str == *startstr) {
status = 1;
}
}
if (status == 1) {
FlyCapture2::Error error;
// Retrieve an image
start = milliseconds_now();
//pgrey.cam.tim
error = pgrey.cam.RetrieveBuffer(&pgrey.rawImage);
FlyCapture2::TimeStamp frametime = pgrey.rawImage.GetTimeStamp();
cout << frametime.seconds << frametime.microSeconds << endl;
//FlyCapture2::TimeStamp
if (error != PGRERROR_OK)
{
pgrey.PrintError(error);
return -1;
}
// Create a converted image
Image convertedImage;
// Convert the raw image
error = pgrey.rawImage.Convert(PIXEL_FORMAT_MONO8, &convertedImage);
if (error != PGRERROR_OK)
{
pgrey.PrintError(error);
return -1;
//.........这里部分代码省略.........