当前位置: 首页>>代码示例>>C++>>正文


C++ write_port函数代码示例

本文整理汇总了C++中write_port函数的典型用法代码示例。如果您正苦于以下问题:C++ write_port函数的具体用法?C++ write_port怎么用?C++ write_port使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了write_port函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init_connection

// init_connection
status_t
init_connection()
{
	status_t error = B_OK;
	// create a port
	outputPort = create_port(10, "common test app port");
	if (outputPort < 0)
		error = outputPort;
	// find the remote port
	port_id port = -1;
	if (error == B_OK) {
		port = find_port(kAppRunnerTeamPort);
		if (port < 0)
			error = port;
	}
	// send the port ID
	if (error == B_OK) {
		ssize_t written = write_port(port, outputPort, &be_app_messenger,
									 sizeof(BMessenger));
		if (written < 0)
			error = written;
	}
	connectionEstablished = (error == B_OK);
	return error;
}
开发者ID:mariuz,项目名称:haiku,代码行数:26,代码来源:CommonTestApp.cpp

示例2: write_port

void
HaikuRTSPClient::NotifyError()
{
	fInterface->ShutdownLoop();
	status_t status = B_ERROR;
	write_port(fInitPort, NULL, &status, sizeof(status));
}
开发者ID:kallisti5,项目名称:haiku,代码行数:7,代码来源:RTSPMediaIO.cpp

示例3: main

int
main()
{
	port_id port = create_port(1, "test port");
	printf("created port %ld\n", port);

	thread_id threads[THREAD_COUNT];
	for (int32 i = 0; i < THREAD_COUNT; i++) {
		threads[i] = spawn_thread(read_thread, "read thread", B_NORMAL_PRIORITY,
			(void*)port);
		resume_thread(threads[i]);
	}

	printf("snooze for a bit, all threads should be waiting now.\n");
	snooze(100000);

	for (int32 i = 0; i < THREAD_COUNT; i++) {
		size_t bytes = 20 + i;
		char buffer[bytes];
		memset(buffer, 0x55, bytes);

		printf("send %ld bytes\n", bytes);
		write_port(port, 0x42, buffer, bytes);
		snooze(10000);
	}

	printf("waiting for threads to terminate\n");
	for (int32 i = 0; i < THREAD_COUNT; i++) {
		wait_for_thread(threads[i], NULL);
	}

	return 0;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:33,代码来源:port_multi_read_test.cpp

示例4: myMessenger

int32 SLooper::FinderThread() { 
        status_t ignored; 

        BMessage msg; 

        // add a BMessenger into msg 
        BMessenger myMessenger(this,this, &ignored); 
        msg.AddMessenger("messageTarget", myMessenger); 
        
        //Flatten it 
        ssize_t messengerBufferLength = msg.FlattenedSize(); 
        char *messengerBuffer = new char[messengerBufferLength]; 
        msg.Flatten(messengerBuffer, messengerBufferLength); 

        // wait for requests to come in 
        port_id toRespondTo; 

        while (read_port(finder, &ignored, &toRespondTo, sizeof(toRespondTo))>=0) { 
                // send requests back to the port ID we were given 
                write_port(toRespondTo, 0, messengerBuffer, messengerBufferLength); 
        } 

        delete messengerBuffer; 
        return 0; 
} 
开发者ID:HaikuArchives,项目名称:BeInYourStereo,代码行数:25,代码来源:SLooper.cpp

示例5: CALLED

void
BTimeSource::DirectRemoveMe(const media_node &node)
{
	// XXX this code has race conditions and is pretty dumb, and it
	// XXX won't detect nodes that crash and don't remove themself.

	CALLED();
	ASSERT(fSlaveNodes != NULL);
	BAutolock lock(fSlaveNodes->locker);

	if (fSlaveNodes->count == 0) {
		ERROR("BTimeSource::DirectRemoveMe no slots used\n");
		return;
	}
	for (int i = 0; i < SLAVE_NODES_COUNT; i++) {
		if (fSlaveNodes->node_id[i] == node.node && fSlaveNodes->node_port[i] == node.port) {
			fSlaveNodes->node_id[i] = 0;
			fSlaveNodes->node_port[i] = 0;
			fSlaveNodes->count -= 1;
			if (fSlaveNodes->count == 0) {
				// stop the time source
				time_source_op_info msg;
				msg.op = B_TIMESOURCE_STOP_IMMEDIATELY;
				msg.real_time = RealTime();
				TRACE_TIMESOURCE("stopping time source %" B_PRId32 "\n", ID());
				write_port(fControlPort, TIMESOURCE_OP, &msg, sizeof(msg));
			}
			return;
		}
	}
	ERROR("BTimeSource::DirectRemoveMe failed\n");
}
开发者ID:mylegacy,项目名称:haiku,代码行数:32,代码来源:TimeSource.cpp

示例6: BMessenger

//////////// == 
// Function to find a remote BLooper 
BMessenger *SLooper::FindOtherEnd(char *unique_name) { 
        BMessenger *rc = new BMessenger(); 
        int32 ignored; 

        FORMULATE_UNIQUE(unique_name);
        
        // find port by name 
        port_id port = find_port(unique); 
        if (port < 0) { 
                return NULL; 
        } 

        // create a port for the reply
        
        port_id myPort = create_port(1, "temporary port for answer"); 
       
        // send the request to the other end with the port of our end 
        write_port(port, 0xdeadbeef, &myPort, sizeof(myPort)); 
        
        // wait for an answer 
        ssize_t messageSize = port_buffer_size(myPort); 
        char *message = new char[messageSize]; 
        read_port(myPort, &ignored, message, messageSize); 

        // get the BMessenger out of it 
        BMessage msg; 
        msg.Unflatten(message); 
        msg.FindMessenger("messageTarget", rc); 
        
        return rc; 
}
开发者ID:HaikuArchives,项目名称:BeInYourStereo,代码行数:33,代码来源:SLooper.cpp

示例7: keyboard_handler_main

void keyboard_handler_main(void)
{
	
	unsigned char status;
	char keycode;
	write_port(0x20, 0x20);

	status = read_port(KEYBOARD_STATUS_PORT);
	if (status & 0x01) {
		keycode = read_port(KEYBOARD_DATA_PORT);

		if(keycode < 0)
			return;
		
		if(keycode == ENTER_KEY_CODE) {
		
			kprint_newline();
			kprint(input);
			reset(input);
			kprint_newline();
			return;
		} else {
			input[counter] = keyboard_map[(unsigned char) keycode];
			counter++;
			}

		vidptr[current_loc++] = keyboard_map[(unsigned char) keycode];
		vidptr[current_loc++] = 0x07;
		
	}
}
开发者ID:giffordxc,项目名称:comp374,代码行数:31,代码来源:kernel.c

示例8: main

int main(){
	int fd1,val;
	char msg[10];
	while(1)
	{
		// Te set brightness
		msg[0] = 0x53;
		msg[1] = 0x00;
		msg[2] = 0x8A; 
		msg[3] = 0x00; 
		msg[4] = 0x00; 
		msg[5] = (int)(val/256); 
		msg[6] = val%256;
		val = msg[1] +msg[2] +msg[3] +msg[4] +msg[5] +msg[6];
		val = val % 0xFF;
		msg[7] = val;
		msg[8] = 0x45;
		msg[9] = '\r';

		fd1=open_port();
		if(fd1 > 0)
                {
                        write_port(msg,10);
                //        delay();
                        close(fd1);
                }
                else
                {
                        printf("Error in Open_port()\n");
                }
        }
        return 0;
}
开发者ID:azad200517,项目名称:Thrermal_Imaging_core_parameters,代码行数:33,代码来源:change_TI_Parameters_through_BB_USB.c

示例9: width_src

void width_src(void){
  unsigned char msg[10];

  msg[0] = '\x1A';
  msg[1] = (unsigned char)param_geti("width_src"); // funkce vraci nulu pokud nenalezne konstantu
  write_port((char *)msg);
}
开发者ID:mjirik,项目名称:mereni-stromu,代码行数:7,代码来源:hardware_config.c

示例10: write_obdmsg

    /*This function creates an OBD commad legible for the OBD and writes it into it.
     * * Arguments:
     *              fd: file descriptor to write in.
     *              buffer: pointer to the buffer where the command is.
     * Return value:
     *              n: number of bytes written.
     *              OBD_WRITE: error while writting.
     */
    int write_obdmsg(int fd, char *msg) {
        char buffer[OBDMSGLEN] = "";

        strncat(buffer, msg, OBDMSGLEN);
        strncat(buffer, LM327_EOLSTRING, OBDMSGLEN);
        return write_port(fd, buffer, strlen(buffer));
    }
开发者ID:asecking,项目名称:TFG,代码行数:15,代码来源:libLM327com.c

示例11: on_socket_event

static void
on_socket_event(void * socket, uint32 event, void * cookie)
{
	connection_cookie * cc = (connection_cookie *) cookie;
	struct socket_event_data sed;
	status_t status;

	if (!cc)
		return;

	if (cc->socket != socket) {
		printf("on_socket_event(%p, %ld, %p): socket is higly suspect! Aborting.\n", socket, event, cookie);
		return;
	}	

	printf("on_socket_event(%p, %ld, %p)\n", socket, event, cookie);

	sed.event = event;
	sed.cookie = cc->notify_cookie;

	// TODO: don't block here => write_port_etc() ?
	status = write_port(cc->socket_event_port, NET_STACK_SOCKET_EVENT_NOTIFICATION,
				&sed, sizeof(sed));
	if (status != B_OK)
		printf("write_port(NET_STACK_SOCKET_EVENT_NOTIFICATION) failure: %s\n",
			strerror(status));
	return;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:28,代码来源:userland_ipc.c

示例12: MainLoop

status_t
MainLoop()
{
	do {
		ssize_t size = port_buffer_size(gRequestPort);
		if (size < B_OK)
			return 0;

		void* buffer = malloc(size);
		if (buffer == NULL)
			return B_NO_MEMORY;
		MemoryDeleter _(buffer);

		int32 code;
		size = read_port(gRequestPort, &code, buffer, size);
		if (size < B_OK)
			return 0;

		status_t result;
		switch (code) {
			case MsgGetAddrInfo:
				result = GetAddrInfo(reinterpret_cast<char*>(buffer));
				break;

			default:
				result = B_BAD_VALUE;
				write_port(gReplyPort, MsgError, &result, sizeof(result));
				result = B_OK;
		}

		if (result != B_OK)
			return 0;
	} while (true);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:34,代码来源:main.cpp

示例13: find_port

filter_result InputFilter::Filter(BMessage *message, BList *outList) {
	
	const int32	kControlKeys = B_COMMAND_KEY | B_SHIFT_KEY;
	
	if (message->what == B_KEY_DOWN ) {

		int32 raw;
		int32 mods;
		
		if ((message->FindInt32("raw_char", 0, (int32 *)&raw) == B_OK)
			&& (message->FindInt32("modifiers", (int32 *)&mods) == B_OK)
			&& (raw==118) // v
			&& ((mods & kControlKeys) == kControlKeys) ) {
			
			port_id port = find_port("ClipUp input port");

			if (port!=B_NAME_NOT_FOUND) {
				write_port( port, 'CtSV', NULL, 0 );
				return B_SKIP_MESSAGE;
			}
		}
	}
	
	return B_DISPATCH_MESSAGE;
}
开发者ID:HaikuArchives,项目名称:ClipUp,代码行数:25,代码来源:InputFilter.cpp

示例14: mutime

/*
 ****************************************************************
 *	Chamada ao sistema "mutime"				*
 ****************************************************************
 */
int
mutime (MUTM *tp)
{
	register int	ticks;
	register int	PIT_val;
	MUTM		mutm;

	/*
	 *	Falta pensar sobre as CPUs N
	 */
	disable_int ();

	write_port (0x00, 0x43);	/* Latch */
	PIT_val = read_port (0x40) + (read_port (0x40) << 8);

	mutm.mu_time = time; 	ticks = hz;

	enable_int ();

	/*
	 *	Agora faz o cálculo
	 */
	mutm.mu_utime = mul_div_64 (ticks, MILHAO, scb.y_hz) +
			mul_div_64 (PIT_init - PIT_val, MILHAO, PIT_FREQ);

	if (unimove (tp, &mutm, sizeof (MUTM), SU) < 0)
		u.u_error = EFAULT;

	return (UNDEF);

}	/* end mutime */
开发者ID:marioaugustorama,项目名称:tropix-kernel,代码行数:36,代码来源:systime.c

示例15: NameToGID

status_t
NameToGID(void* buffer)
{
	char* groupName = reinterpret_cast<char*>(buffer);
	
	struct group* groupInfo = NULL;

	if (MatchDomain(groupName) == B_OK)
		groupInfo = getgrnam(groupName);

	if (groupInfo == NULL) {
		return write_port(gReplyPort, MsgReply, &gNogroupId,
			sizeof(gNogroupId));
	}

	return write_port(gReplyPort, MsgReply, &groupInfo->gr_gid, sizeof(gid_t));
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:17,代码来源:IdMapper.cpp


注:本文中的write_port函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。