亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? orc.c

?? 卡內基梅隆大學(CMU)開發的移動機器人控制開發軟件包。可對多種機器人進行控制
?? C
?? 第 1 頁 / 共 2 頁
字號:
 /********************************************************* * * This source code is part of the Carnegie Mellon Robot * Navigation Toolkit (CARMEN) * * CARMEN Copyright (c) 2002 Michael Montemerlo, Nicholas * Roy, Sebastian Thrun, Dirk Haehnel, Cyrill Stachniss, * and Jared Glover * * CARMEN is free software; you can redistribute it and/or  * modify it under the terms of the GNU General Public  * License as published by the Free Software Foundation;  * either version 2 of the License, or (at your option) * any later version. * * CARMEN is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE.  See the GNU General Public License for more  * details. * * You should have received a copy of the GNU General  * Public License along with CARMEN; if not, write to the * Free Software Foundation, Inc., 59 Temple Place,  * Suite 330, Boston, MA  02111-1307 USA * ********************************************************/#include <stdlib.h>#include <stdio.h>#include <pthread.h>#include <signal.h>#include <string.h>#include <errno.h>#include <unistd.h>#include <stdint.h>#include <stdarg.h>#include "orc.h"#include "packet.h"#include "timespec.h"#include "clog.h"#include "log.h"#include "orcconstants.h"static uint8_t garbage[256];#define VPRINTALLOC                                                \	int sz = 4096;						   \	char *buf = NULL;                                          \	_revprintf:                                                \        buf = (char*) realloc(buf,sz);	               		   \	va_list ap;                                                \	int len;                                                   \	va_start(ap, fmt);                                         \	len = vsnprintf(buf, sz-1, fmt, ap);                       \	if (len < 0 || len>=sz)                                    \            { sz*=2; goto _revprintf; }                            \	va_end(ap);                                                static ssize_t read_fully(int fd, uint8_t *buf, ssize_t count){        ssize_t readsofar = 0;        ssize_t readthistime;        while (readsofar < count) {                readthistime = read(fd, &buf[readsofar], count - readsofar);                if (readthistime < 0) {			LOG_ERROR("ERROR: read failed with %ld (%s)\n", (long) readthistime, strerror(errno));                        return -1; // error!                }                if (readthistime == 0) {                        LOG_ERROR("ERROR: got EOF while reading %ld\n", (long) readthistime);                        return -1; // that's an error for us.                }                readsofar += readthistime;        }        return readsofar;}static ssize_t write_fully(int fd, uint8_t *buf, ssize_t count){        ssize_t writtensofar = 0;        ssize_t writtenthistime;        while (writtensofar < count) {                writtenthistime = write(fd, &buf[writtensofar], count - writtensofar);                if (writtenthistime <= 0)                        return -1;                writtensofar += writtenthistime;        }        return writtensofar;}static void setup_thread(){	int ot;	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,&ot);	signal(SIGPIPE, SIG_IGN);}static void handle_heartbeat_packet(orc_t *orc, uint8_t *p){	orc->heartbeat_time = packet_16u(p, 3);	orc->heartbeat_flags = packet_8u(p, 7);}static void handle_pad_packet(orc_t *orc, uint8_t *p){	orc->pad_switches = p[PACKET_DATA + 1];	orc->pad_updown = p[PACKET_DATA + 2];	orc->pad_leftright = p[PACKET_DATA + 3];	orc->pad_joyx = p[PACKET_DATA + 4];	orc->pad_joyy = p[PACKET_DATA + 5];	pthread_mutex_lock(&orc->pad_mutex);	pthread_cond_broadcast(&orc->pad_cond);	pthread_mutex_unlock(&orc->pad_mutex);}void *reader_thread(void *_arg){	orc_t *orc = (orc_t*) _arg;	setup_thread();	orc->fd = -1;	int reconnectcount = 0;reconnect:		// reconnect, if necessary.	while (orc->fd < 0) {		LOG_INFO("Trying to connect to orcboard...(%i)", reconnectcount++);		orc->fd = orc->impl->connect(orc->impl);				if (orc->fd < 0)			sleep(1);	}	// read for a while	while (1) {		// read a packet		uint8_t buf[3];		int res = read_fully(orc->fd, buf, 1);		if (res <= 0)			goto disconnected;		if (buf[0] != 0xED) {			LOG_DEBUG("Recovering sync [%02X]", buf[0]);			continue;		}		res = read_fully(orc->fd, &buf[1], 2);		if (res <= 0)			goto disconnected;		int id = buf[1];		int datalen = buf[2];		transaction_t *t = &orc->transactions[id];		memcpy(t->response, buf, 3);		res = read_fully(orc->fd, &t->response[PACKET_DATA], datalen + 1);		if (res <= 0)			goto disconnected;		if (!packet_test_checksum(t->response)) {			LOG_WARN("Bad checksum received from Orc");			continue;		}		if (t->response == garbage && t->response[1]>=orc->idLow && t->response[1]<=orc->idHigh)			LOG_VERBOSE("Unsolicited ack, id = %02X", t->response[1]);		// is this a message from orcd, assigning us a client id?		if (t->response[1] == 0xf7) {			orc->idLow = t->response[4];			orc->idHigh = t->response[5];			orc->idLast = orc->idLow;			LOG_INFO("Got client transaction range: %02x-%02x", orc->idLow, orc->idHigh);		}		if (t->response[1] == 0xfe)			handle_pad_packet(orc, t->response);		if (t->response[1] == PACKET_ID_ORCBOARD_BROADCAST &&		    packet_16u(t->response, 1) == MSG_ASYNC_HEARTBEAT)			handle_heartbeat_packet(orc, t->response);		pthread_mutex_lock(&t->mutex);		pthread_cond_signal(&t->cond);		pthread_mutex_unlock(&t->mutex);	}	disconnected:	orc->impl->disconnect(orc->impl, orc->fd);	orc->fd = -1;	goto reconnect;	// silence compiler	return NULL;}orc_t *orc_create(orc_comms_impl_t *impl){	orc_t *orc = (orc_t*) calloc(sizeof(orc_t), 1);	orc->impl = impl;	pthread_attr_t threadAttr;	pthread_attr_init(&threadAttr);	pthread_attr_setstacksize(&threadAttr, 32768);	pthread_t newthread;	if (pthread_create(&newthread, &threadAttr, reader_thread, orc)) {		LOG_ERROR("Couldn't create orc reader thread: %s", strerror(errno));		exit(EXIT_FAILURE);	}	for (int i = 0; i < 256; i++) {		pthread_mutex_init(&orc->transactions[i].mutex, NULL);		pthread_cond_init(&orc->transactions[i].cond, NULL);		orc->transactions[i].inuse = 0;		orc->transactions[i].response = garbage;	}	pthread_mutex_init(&orc->writeLock, NULL);	pthread_mutex_init(&orc->idMutex, NULL);	pthread_cond_init(&orc->idCond, NULL);	orc->idUsed = 0;	orc->idLow = 0x00; // initially, we can use any id	orc->idHigh = 0xef;	orc->idLast = orc->idLow;	pthread_mutex_init(&orc->pad_mutex, NULL);	pthread_cond_init(&orc->pad_cond, NULL);	orc_null(orc, 0, 0);	return orc;}void orc_destroy(orc_t *orc){	free(orc);}static int alloc_transaction_id(orc_t *orc){	int id;	pthread_mutex_lock(&orc->idMutex);	// wait for a transaction to become available	int max = orc->idHigh - orc->idLow + 1;	while (orc->idUsed >= max)		pthread_cond_wait(&orc->idCond, &orc->idMutex);			// search for a transaction id, beginning our search at idLast	do {		orc->idLast++;		if (orc->idLast > orc->idHigh)			orc->idLast = orc->idLow;	} while (orc->transactions[orc->idLast].inuse);	// initialize the transaction	id = orc->idLast;		orc->idUsed++;	pthread_mutex_unlock(&orc->idMutex);	return id;}static void free_transaction_id(orc_t *orc, int id){	pthread_mutex_lock(&orc->idMutex);	orc->transactions[id].inuse = 0;	orc->idUsed--;	pthread_cond_signal(&orc->idCond);	pthread_mutex_unlock(&orc->idMutex);}int orc_transaction_once(orc_t *orc, uint8_t *request, uint8_t *response){	while (orc->fd <= 0) {		usleep(1000);	}		// grab an id	int id = alloc_transaction_id(orc);	// fix up the packet.	request[0] = PACKET_MARKER;	request[PACKET_ID] = id;	packet_fill_checksum(request);	// fill out the transaction record	transaction_t *t = &orc->transactions[id];	pthread_mutex_lock(&t->mutex);	t->response = response;	// send the packet	pthread_mutex_lock(&orc->writeLock);	write_fully(orc->fd, request, request[PACKET_DATALEN] + 4);	pthread_mutex_unlock(&orc->writeLock);	// compute our timeout time	struct timespec ts;	timespec_now(&ts);	timespec_addms(&ts, 100);		// wait!	int res = pthread_cond_timedwait(&t->cond, &t->mutex, &ts);	t->response = garbage;		// cleanup	pthread_mutex_unlock(&t->mutex);	free_transaction_id(orc, id);	if (res == ETIMEDOUT) {		LOG_VERBOSE("Timeout packet, id = %02X", id);		return -1;	}	return 0;}void orc_transaction_async(orc_t *orc, uint8_t *request){	// fix up the packet.	request[0] = PACKET_MARKER;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本午夜精品视频在线观看 | 欧美伊人久久久久久久久影院| 亚洲国产成人av网| 亚洲精品欧美综合四区| 亚洲欧洲成人av每日更新| 久久久久久久久蜜桃| 国产视频一区在线观看 | 成人性生交大片免费 | 亚洲色图欧美激情| 亚洲男人的天堂在线aⅴ视频| 亚洲欧美日韩在线不卡| 亚洲一区二区三区免费视频| 亚洲线精品一区二区三区| 三级不卡在线观看| 毛片av中文字幕一区二区| 久久丁香综合五月国产三级网站| 人人精品人人爱| 麻豆免费精品视频| 高清久久久久久| 色综合天天综合色综合av| 91国内精品野花午夜精品| 欧美理论片在线| 久久综合色鬼综合色| 国产精品伦理在线| 五月天婷婷综合| 国产在线看一区| 91香蕉视频mp4| 欧美一区二区三区日韩| 久久久精品国产99久久精品芒果| 亚洲色图视频网站| 久久99久久99精品免视看婷婷| 成人av影视在线观看| 欧美老人xxxx18| 中文一区一区三区高中清不卡| 亚洲夂夂婷婷色拍ww47| 国产成人亚洲综合色影视| 色综合久久久久综合体桃花网| 91精品在线免费| 国产精品久久毛片| 麻豆精品在线播放| 色婷婷香蕉在线一区二区| 久久嫩草精品久久久久| 亚洲欧美另类小说| 国产在线精品国自产拍免费| 欧美在线你懂的| 国产精品美女久久久久久久| 美女在线视频一区| 欧美羞羞免费网站| 国产精品视频一二三区| 精品在线亚洲视频| 欧美三级韩国三级日本三斤| 亚洲国产高清在线观看视频| 美女一区二区视频| 欧美挠脚心视频网站| 亚洲免费观看高清完整版在线| 久久国产人妖系列| 欧美久久久久中文字幕| 亚洲久本草在线中文字幕| 国产精品自拍在线| 日韩欧美的一区二区| 一区二区三区精品视频在线| 99久久精品情趣| 国产日韩欧美精品电影三级在线| 日本在线不卡一区| 欧美日韩国产一级| 亚洲v日本v欧美v久久精品| 一本大道av伊人久久综合| 日本一区二区免费在线观看视频| 精品中文av资源站在线观看| 欧美电影在哪看比较好| 午夜不卡av在线| 欧美探花视频资源| 亚洲一区在线播放| 欧美影院一区二区| 亚洲国产综合色| 欧美日韩午夜影院| 舔着乳尖日韩一区| 日韩美女视频一区二区在线观看| 男女性色大片免费观看一区二区| 欧美艳星brazzers| 天天综合网 天天综合色| 欧美高清视频一二三区 | 精品国产91久久久久久久妲己| 男女男精品网站| 2021国产精品久久精品| 国产成人综合网| 成人免费在线视频| 欧美伊人久久大香线蕉综合69 | 国产精品福利一区| 91麻豆国产在线观看| 亚洲chinese男男1069| 91精品免费观看| 国产一区二区美女诱惑| 国产精品久久一级| 欧美日韩中文字幕一区二区| 琪琪一区二区三区| 2020国产成人综合网| 成人午夜激情影院| 一区二区不卡在线播放| 精品欧美一区二区久久| 成人黄页在线观看| 亚洲国产成人tv| 久久久影院官网| 91日韩精品一区| 全国精品久久少妇| 国产网红主播福利一区二区| 色综合久久久久网| 久久www免费人成看片高清| 中文字幕一区二区三区蜜月| 在线电影院国产精品| 国产福利一区二区三区视频在线 | 91麻豆精品国产91久久久久 | 欧洲生活片亚洲生活在线观看| 日本不卡视频一二三区| 亚洲婷婷综合色高清在线| 欧美男同性恋视频网站| www.av亚洲| 琪琪久久久久日韩精品| 亚洲制服丝袜av| 国产精品人妖ts系列视频| 日韩一区二区在线免费观看| 91免费观看视频| 国产精品中文有码| 日韩av电影免费观看高清完整版 | 久久久久99精品一区| 色素色在线综合| 国产高清无密码一区二区三区| 日本欧洲一区二区| 亚洲综合一区在线| 最新中文字幕一区二区三区| 欧美成人福利视频| 欧美日韩一区二区三区免费看| 91网上在线视频| av在线不卡电影| 国产一区二区在线免费观看| 亚洲h在线观看| 亚洲国产精品久久人人爱| 国产精品传媒入口麻豆| 欧美—级在线免费片| 久久美女高清视频| 久久毛片高清国产| 久久嫩草精品久久久精品一| 精品国产乱码久久久久久影片| 91精品国产色综合久久久蜜香臀| 91成人网在线| 在线观看视频一区| 在线免费观看日韩欧美| 在线亚洲一区二区| 欧美视频完全免费看| 91猫先生在线| 91美女视频网站| 在线看不卡av| 欧美日韩一级二级三级| 欧美日韩免费高清一区色橹橹| 欧美综合亚洲图片综合区| 欧美在线观看一二区| 欧美视频在线一区二区三区| 欧美在线免费视屏| 这里只有精品免费| 精品成人在线观看| 久久久久久久久久久电影| 中文字幕精品三区| 国产精品久久一级| 夜夜嗨av一区二区三区中文字幕| 亚洲美女区一区| 天天射综合影视| 久久精品国产澳门| 成人精品小蝌蚪| 欧美少妇一区二区| 欧美一区二区免费| 久久综合久色欧美综合狠狠| 国产精品视频线看| 午夜精品久久久久影视| 美女在线一区二区| 国产99久久久久久免费看农村| 99r国产精品| 欧美日韩高清一区| 精品国产一区二区三区不卡| 国产欧美日韩亚州综合| 亚洲精品国产第一综合99久久 | 91精品国产色综合久久不卡蜜臀| 精品av久久707| 中文字幕在线一区二区三区| 亚洲国产精品一区二区久久 | 日韩精品一区二区在线| 久久久国产精品麻豆| 亚洲三级免费电影| 免费观看一级特黄欧美大片| 成人免费视频免费观看| 在线日韩国产精品| 国产偷国产偷亚洲高清人白洁| 一片黄亚洲嫩模| 国产盗摄一区二区三区| 欧美三级电影在线观看| 国产欧美日韩三级| 美女脱光内衣内裤视频久久网站 | 99免费精品视频| 欧美电影免费观看高清完整版在| 国产精品大尺度| 精品一区二区三区免费毛片爱|