线程或进程独占CPU一般用来相对地提升实时性,但也不要指忘达到真正的实时操作系统的性能. 进程邦定CPU 我们通过系统调用sched_setaffinity进行绑定,通过sched_getaffinity获取绑定关系。注意这对方法是进程级别的绑定。代码中指定cpu0和cpu3,我们可以通过htop查看,两个cpu使用达到了100%,其他的……
qt network相关
获取所有活动网卡
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
int ipInc = 0; QStringList ipList; ipList.clear(); QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); QList<QNetworkInterface> ipDevList = QNetworkInterface::allInterfaces(); #ifdef Q_OS_ANDROID ipList << "Android Boardcast"; #endif for (int i = 0; i < ipDevList.size(); ++i) { bool ipReady = false; QList<QNetworkAddressEntry> tmpIPlist = ipDevList.at(i).addressEntries(); // 排除所有未连接的网卡 QNetworkInterface tmpNet = ipDevList.at(i); QNetworkInterface::InterfaceFlags interFlags; interFlags = tmpNet.flags(); if(!((interFlags&QNetworkInterface::IsUp) && (interFlags&QNetworkInterface::IsRunning) && (interFlags&QNetworkInterface::CanBroadcast) && (interFlags&QNetworkInterface::CanMulticast) && !(interFlags&QNetworkInterface::IsLoopBack))) { continue; } QString tmpIp; for (int y=0; y<tmpIPlist.size(); ++y) { QNetworkAddressEntry xx = tmpIPlist.at(y); if (xx.ip() != QHostAddress::LocalHost && xx.ip().toIPv4Address() ) { ipReady = true; tmpIp = xx.ip().toString(); break; } } if( true == ipReady ) { ipList << tmpIp + " (" + ipDevList.at(i).humanReadableName() + ")"; if( tmpIp == lastUdpIp ) { autoLinkIpSeqInList = ipInc; } ipInc++; } } qDebug() << "ipList:" << ipList; |
在TCP SERVER中获取CLIENT的IP及端口
1 2 3 4 5 6 7 |
//clientIP = tcpSocket->peerAddress().toString(); // 网上的这种方法不可用,会多出来一些字符 quint32 ipv4 = tcpSocket->peerAddress().toIPv4Address(); char xx[30]; sprintf(xx, "%d.%d.%d.%d",ipv4>>24,(ipv4>>16)&0xFF,(ipv4>>8)&0xFF ,ipv4&0xFF); clientIP = xx; clientPort = tcpSocket->peerPort(); |
‘Access-Control-Allow-Origin’跨域问题解决 (vue axios)
uboot下备份镜像
QT VirtualKeyboard 插件编译与使用
使用JavaScript对json数组的各种处理方法 filter map forEach..
vue学习笔记
基本操作 js文件 <script src=”js/vue.js”></script> 就收工了.正式环境用 vue.min.js v-for对json数据的邦定 当点击时某个按钮时,更改自已与其他对象的css
1 2 3 4 5 6 7 8 9 10 11 |
<div id="insource" class="col-xs-12"> <hr> <span class="btn btn-app btn-sm btn-pink no-hover" v-for="abc in items"> <P></P> <span class="line-height-1 smaller-90">{{ abc.alias }}</span> <p> <span class="line-height-1 smaller-60">{{ abc.id + ":" + abc.type }}</span> </p> <p> <span class="line-height-1 smaller-80">{{ abc.group }}</span> </p> <span class="badge badge-warning badge-left">电视墙</span> </span> </div> |
[crayon-64266faedbb……
jQuery 学习笔记一
基本用法 get数据
1 2 3 4 5 6 7 |
function loadXMLDoc_justchen() { $.get("/action/led", function (data, status) { // GET 参数,回调函数(参数,状态) $("#NODE-SN").text(data); // 查找到ID为NODE-SN的项目并将其更改为文本 //console.log(data); }); } |
当面页ready 后加载数据
1 2 3 4 |
$(document).ready(function () { loadXMLDoc_justchen(); }); |
定时刷新数据 实际上就是加入 setInterval 方法 setInterval() 方法可按照指定的周期(以毫秒计)来调用函数或计算表达式。 setIn……
GoaHead 学习笔记
初始化及基本流程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
int goahdStart(void) { char *argp, *auth, *home, *documents, *endpoints, *endpoint, *route, *tok, *lspec; int argind, duration; route = "route.txt"; auth = "auth.txt"; duration = 0; logSetPath("stdout:2"); // 打印 documents = ME_GOAHEAD_DOCUMENTS; //initPlatform(); if (websOpen(documents, route) < 0) { error("初始化WEB系统失败. Exiting."); return -1; } logHeader(); if (websLoad(auth) < 0) { error("Cannot load %s", auth); return -1; } if (websListen("http://*:80") < 0) { return -1; } websDefineHandler("test", testHandler, nullptr, nullptr, 0); websAddRoute("/test", "test", 0); websDefineAction("exampleAction", (void*)exampleAction); if (websGetBackground()) { if (daemon(0, 0) < 0) { error("Cannot run as daemon"); return -1; } } websServiceEvents(&finished); return 0; } |
goActions goActions定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
static void exampleAction(Webs *wp) { const char *io_val; io_val = websGetVar(wp, "val_led", nullptr); // 获取POST过来的数据 qDebug() << "on_led_set: " << io_val; websSetStatus(wp, 200); websWriteHeaders(wp, -1, nullptr); websWriteEndHeaders(wp); websWrite(wp, "%s", "<h4>hello GoAction!</h4>"); // 返回数据 websDone(wp); return nullptr; /****这句注册一个可以通过action/exampleGetAction访问的GoAction函数****/ websDefineAction("exampleAction", exampleGetAction); |