亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
久久人人爽人人爽| 日产精品久久久久久久性色| 亚洲国产va精品久久久不卡综合| 青青草国产成人av片免费| 处破女av一区二区| 精品动漫一区二区三区在线观看| 自拍偷拍国产亚洲| 国产精品影视天天线| 欧美二区三区91| 亚洲精品老司机| 成人免费高清视频在线观看| 日韩午夜在线播放| 日韩国产欧美在线播放| 91影院在线观看| 国产日韩精品一区二区三区| 美女视频免费一区| 欧美日韩国产影片| 亚洲综合免费观看高清在线观看 | 国产日韩一级二级三级| 首页国产欧美久久| 欧美女孩性生活视频| 一区二区三区在线免费观看 | 国产日本欧洲亚洲| 久久丁香综合五月国产三级网站| 欧美日韩免费观看一区三区| 亚洲视频一区在线观看| 99精品欧美一区二区三区小说 | 成人精品鲁一区一区二区| 欧美mv日韩mv亚洲| 久久国产精品99精品国产 | 久久久亚洲精品一区二区三区| 男女男精品视频网| 欧美一级高清大全免费观看| 日韩精品成人一区二区三区 | 色噜噜久久综合| 一区二区激情小说| 色成人在线视频| 一区二区三区不卡视频| 色视频一区二区| 亚洲欧美日韩一区二区| 在线看日本不卡| 天堂久久久久va久久久久| 欧美久久一区二区| 麻豆精品精品国产自在97香蕉| 日韩美一区二区三区| 黄色精品一二区| 中国色在线观看另类| 色婷婷av一区二区三区之一色屋| 亚洲欧美国产77777| 欧美特级限制片免费在线观看| 日韩主播视频在线| 久久久国产一区二区三区四区小说 | 欧美一区二区黄色| 激情六月婷婷久久| 国产精品剧情在线亚洲| 在线亚洲+欧美+日本专区| 亚洲成人免费影院| 久久久午夜精品理论片中文字幕| 不卡的av电影在线观看| 一区二区三区产品免费精品久久75| 欧美日韩第一区日日骚| 国产一区二区三区在线观看精品| 国产精品精品国产色婷婷| 欧美日韩国产中文| 国产成人午夜99999| 亚洲国产精品一区二区www| 精品欧美一区二区久久| jlzzjlzz欧美大全| 美女免费视频一区二区| 亚洲欧洲一区二区在线播放| 9191久久久久久久久久久| 国产麻豆精品久久一二三| 亚洲欧美视频在线观看视频| 日韩一级精品视频在线观看| 国产一区二区福利视频| 夜夜嗨av一区二区三区中文字幕| 久久青草国产手机看片福利盒子 | 国产激情一区二区三区四区| 亚洲国产中文字幕在线视频综合| 日韩欧美中文字幕精品| 91亚洲国产成人精品一区二三 | 日韩欧美一级二级三级久久久| 国产精品99久久久久久有的能看| 亚洲综合偷拍欧美一区色| 久久久青草青青国产亚洲免观| 日本韩国欧美一区二区三区| 国产不卡视频在线播放| 天堂一区二区在线| 亚洲三级在线免费观看| 久久免费看少妇高潮| 欧美三级视频在线| 91污片在线观看| 国产精品自在欧美一区| 麻豆国产精品777777在线| 一区二区三区精品在线| 国产精品国产三级国产| 久久精品亚洲精品国产欧美kt∨| 91麻豆精品91久久久久久清纯| 91丨九色丨黑人外教| 成人激情黄色小说| 高清国产午夜精品久久久久久| 国内外精品视频| 久久99精品视频| 另类调教123区| 蜜臀99久久精品久久久久久软件| 亚洲一区二区在线观看视频| 亚洲欧美另类久久久精品 | 美女视频免费一区| 日日夜夜精品免费视频| 亚洲高清视频的网址| 亚洲精品乱码久久久久久日本蜜臀| 一区二区中文视频| 亚洲品质自拍视频网站| 中文字幕视频一区二区三区久| 欧美激情综合五月色丁香| 久久久久久久精| 国产精品亲子乱子伦xxxx裸| 亚洲国产高清在线观看视频| 国产精品亲子伦对白| 国产精品福利av| 一区二区三区四区不卡视频| 亚洲午夜久久久久久久久久久| 一区二区三区成人在线视频| 亚洲一区免费在线观看| 日韩精品电影在线观看| 免费美女久久99| 国产成人免费9x9x人网站视频| 国产成人精品午夜视频免费| 成人午夜视频在线| 色香蕉成人二区免费| 在线日韩一区二区| 日韩视频一区二区| 国产亚洲精品aa| 樱桃国产成人精品视频| 午夜欧美电影在线观看| 美女视频黄a大片欧美| 国产一区二区视频在线| www.久久久久久久久| 色婷婷亚洲一区二区三区| 欧美精品在线观看播放| 精品国产区一区| 中文字幕一区二区三区乱码在线| 亚洲福利电影网| 国产美女精品一区二区三区| jvid福利写真一区二区三区| 欧日韩精品视频| 欧美va亚洲va香蕉在线| 中文字幕一区不卡| 日韩国产欧美在线视频| 福利一区二区在线| 欧美日韩免费一区二区三区视频| 久久久天堂av| 亚洲成人黄色小说| 成人aaaa免费全部观看| 欧美日韩国产高清一区二区三区 | 国产剧情在线观看一区二区| 波多野结衣的一区二区三区| 欧美影院精品一区| 国产视频不卡一区| 亚洲国产色一区| 东方aⅴ免费观看久久av| 欧美日韩你懂得| 国产精品成人一区二区艾草| 日韩专区欧美专区| 色综合色狠狠综合色| 久久伊99综合婷婷久久伊| 亚洲一二三区不卡| 成人av资源站| 久久综合久色欧美综合狠狠| 亚洲美女视频在线| 成人a级免费电影| 日韩精品一区二区三区四区| 洋洋成人永久网站入口| 成人一级黄色片| 久久理论电影网| 蜜桃av一区二区在线观看| 欧美性一区二区| 亚洲丝袜自拍清纯另类| 成人午夜激情影院| 久久女同精品一区二区| 美国一区二区三区在线播放| 欧美日韩黄视频| 亚洲韩国精品一区| 91国产免费观看| 国产精品成人免费在线| 国产福利视频一区二区三区| 欧美一二三四区在线| 午夜精品aaa| 欧美色视频在线观看| 亚洲精品国产第一综合99久久| 成人精品视频一区二区三区尤物| 久久久精品国产免大香伊| 激情成人综合网| 久久亚洲影视婷婷| 国产精品夜夜爽| 国产亚洲欧美在线| 丁香激情综合国产| 国产午夜一区二区三区| 国产成人综合亚洲网站| 国产无人区一区二区三区|