C++ 如何在Mac上独占访问usb设备
我正在使用库将数据包发送到我的邮箱,但并不是所有发送的数据包都被接收到。我错过了什么。我怎样才能使它不会跳过任何数据包,因为它对我的项目非常关键C++ 如何在Mac上独占访问usb设备,c++,xcode,macos,usb,C++,Xcode,Macos,Usb,我正在使用库将数据包发送到我的邮箱,但并不是所有发送的数据包都被接收到。我错过了什么。我怎样才能使它不会跳过任何数据包,因为它对我的项目非常关键 #ifndef Pctx_hpp #define Pctx_hpp extern "C" { #include "hid.h" } #include <stdio.h> class Pctx { public: Pctx(int Vendoreid=0x0925,int productid=0x1299); ~Pctx();
#ifndef Pctx_hpp
#define Pctx_hpp
extern "C" {
#include "hid.h"
}
#include <stdio.h>
class Pctx
{
public:
Pctx(int Vendoreid=0x0925,int productid=0x1299);
~Pctx();
bool transmite(int channel1,int channel2,int channel3,int channel4,int channel5,int channel6,int channel7,int channel8);
bool transmite(int channel, char value);
private:
int productid;
int vendorid;
char buffer[32];
};
#endif /* Pctx_hpp */
当我运行这个程序时,它会编译,但实际上并没有发送所有的数据包,有时会跳过一些
#include <iostream>
#include "Pctx.hpp"
#include <unistd.h>
using namespace std;
#include "hid.h"
int main() {
Pctx radio;
radio.transmite(1, 120);
while (true) {
radio.transmite(1, 200);
cout<<200<<endl;
sleep(5);
radio.transmite(1,69);
cout<<69<<endl;
sleep(5);
}
return 0;
}`
#包括
#包括“Pctx.hpp”
#包括
使用名称空间std;
#包括“hid.h”
int main(){
Pctx无线电;
无线电传输(1120);
while(true){
无线电传输(1200);
这可以在一行中完成!buffer[0]=0;buffer[1]=0;buffer[2]=0;buffer[3]=0;/…
这可以在一行中完成!
#include <iostream>
#include "Pctx.hpp"
#include <unistd.h>
using namespace std;
#include "hid.h"
int main() {
Pctx radio;
radio.transmite(1, 120);
while (true) {
radio.transmite(1, 200);
cout<<200<<endl;
sleep(5);
radio.transmite(1,69);
cout<<69<<endl;
sleep(5);
}
return 0;
}`