Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 90b0f19cb1d7e9203fc3b892ef2d9b55c5e4f5c5 (plain) (blame)
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
/*******************************************************************************
 * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Thomas Schuetz (initial contribution)
 *
 *******************************************************************************/

#include "modelbase/etPort.h"

#include "debugging/etMSCLogger.h"
#include "platform/etMemory.h"
#include <string.h>

void etPort_receive(const etPort* self, const etMessage* msg) {
	ET_MSC_LOGGER_SYNC_ENTRY("etPort", "receive")
	if (self->receiveMessageFunc!=NULL)
		(self->receiveMessageFunc)(self->myActor, (void*)self, msg);
	ET_MSC_LOGGER_SYNC_EXIT
}


void etPort_sendMessage(const etPort* self, etInt16 evtId, int size, void* data) {
	int offset = MEM_CEIL(sizeof(etMessage));
	int totalSize = offset+size;
	etMessage* msg = etMessageService_getMessageBuffer(self->msgService, totalSize);
	if (msg!=NULL) {
		msg->address = self->peerAddress;
		msg->evtID = evtId;

		if (size>0 && data!=NULL) {
			memcpy(((char*)msg)+offset, data, size);
		}

		etMessageService_pushMessage(self->msgService, msg);
	}
}

Back to the top