mirror of
https://github.com/espressif/openthread.git
synced 2026-10-10 17:57:48 +00:00
enable parallel builds (#303)
* add automate test-driver for openthread * enable parallel builds and tests * enable adding flags to compiler * Fix typo
This commit is contained in:
committed by
Jonathan Hui
parent
5f9f9e2ce2
commit
309685f9f0
@@ -36,6 +36,7 @@
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -49,12 +50,20 @@ uint32_t WELLKNOWN_NODE_ID = 34;
|
||||
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NODE_ID = atoi(argv[1]);
|
||||
NODE_ID = strtol(argv[1], &endptr, 0);
|
||||
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
fprintf(stderr, "Invalid NODE_ID: %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
posixAlarmInit();
|
||||
posixRadioInit();
|
||||
|
||||
@@ -111,6 +111,7 @@ static uint16_t sPanid;
|
||||
static int sSockFd;
|
||||
static bool sPromiscuous = false;
|
||||
static bool sAckWait = false;
|
||||
static uint16_t sPortOffset = 0;
|
||||
|
||||
static inline bool isFrameTypeAck(const uint8_t *frame)
|
||||
{
|
||||
@@ -308,16 +309,34 @@ void otPlatRadioSetPromiscuous(bool aEnable)
|
||||
void posixRadioInit(void)
|
||||
{
|
||||
struct sockaddr_in sockaddr;
|
||||
char *offset;
|
||||
memset(&sockaddr, 0, sizeof(sockaddr));
|
||||
sockaddr.sin_family = AF_INET;
|
||||
|
||||
offset = getenv("PORT_OFFSET");
|
||||
|
||||
if (offset)
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
sPortOffset = strtol(offset, &endptr, 0);
|
||||
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
fprintf(stderr, "Invalid PORT_OFFSET: %s\n", offset);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sPortOffset *= WELLKNOWN_NODE_ID;
|
||||
}
|
||||
|
||||
if (sPromiscuous)
|
||||
{
|
||||
sockaddr.sin_port = htons(9000 + WELLKNOWN_NODE_ID);
|
||||
sockaddr.sin_port = htons(9000 + sPortOffset + WELLKNOWN_NODE_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
sockaddr.sin_port = htons(9000 + NODE_ID);
|
||||
sockaddr.sin_port = htons(9000 + sPortOffset + NODE_ID);
|
||||
}
|
||||
|
||||
sockaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
@@ -520,7 +539,7 @@ void radioTransmit(const struct RadioMessage *msg, const struct RadioPacket *pkt
|
||||
continue;
|
||||
}
|
||||
|
||||
sockaddr.sin_port = htons(9000 + i);
|
||||
sockaddr.sin_port = htons(9000 + sPortOffset + i);
|
||||
rval = sendto(sSockFd, msg, 1 + pkt->mLength,
|
||||
0, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
|
||||
assert(rval >= 0);
|
||||
|
||||
Reference in New Issue
Block a user