Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpu/native/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void _native_call_sig_handlers_and_switch(void)
warnx("call sig handlers + switch: ignoring SIGUSR1");
}
else {
errx(EXIT_FAILURE, "XXX: no handler for signal %i\nXXX: this should not have happened!\n", sig);
//warnx( "XXX: no handler for signal %i\nXXX: this should not have happened!\n", sig);
}
}

Expand All @@ -293,6 +293,7 @@ void native_signal_action(int sig, siginfo_t *info, void *context)
if (thread_get_active() == NULL) {
_native_in_isr++;
warnx("native_signal_action: thread_get_active() is null - unhandled");

_native_in_isr--;
return;
}
Expand Down
29 changes: 22 additions & 7 deletions cpu/native/periph/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>

Expand Down Expand Up @@ -43,6 +46,7 @@ static int tty_fds[UART_NUMOF];

void tty_uart_setup(uart_t uart, const char *filename)
{
//DEBUG("UART SETUP");
tty_device_filenames[uart] = strndup(filename, PATH_MAX - 1);
}

Expand Down Expand Up @@ -92,7 +96,8 @@ static void io_signal_handler(int fd, void *arg)

int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
{
if (uart >= UART_NUMOF) {
//DEBUG("UART INIT");
if (uart >= UART_NUMOF) {
return UART_NODEV;
}

Expand Down Expand Up @@ -147,21 +152,30 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)

cfsetospeed(&termios, speed);
cfsetispeed(&termios, speed);

tty_fds[uart] = real_open(tty_device_filenames[uart], O_RDWR | O_NONBLOCK);

if (tty_fds[uart] < 0) {
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, tty_device_filenames[uart]);
unlink(tty_device_filenames[uart]);
bind(fd, (struct sockaddr *) &addr, sizeof(addr));
real_write(1, "Listening...\n", 13);
listen(fd, 1);
real_write(1, "Accepting...\n", 13);
tty_fds[uart] = accept(fd, NULL, NULL);//real_open(tty_device_filenames[uart], O_RDWR | O_NONBLOCK);
real_write(1, "Accepted!...\n", 13);
int i = tty_fds[uart];
if (i < 0) {
return UART_INTERR;
}

tcsetattr(tty_fds[uart], TCSANOW, &termios);
//tcsetattr(tty_fds[uart], TCSANOW, &termios);

uart_config[uart].rx_cb = rx_cb;
uart_config[uart].arg = arg;

native_async_read_setup();
native_async_read_add_handler(tty_fds[uart], NULL, io_signal_handler);

//DEBUG("UART_OK");
return UART_OK;
}

Expand All @@ -181,6 +195,7 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
DEBUG("\n");

if (tty_fds[uart] >= 0) {
real_write(1, data, len);
_native_write(tty_fds[uart], data, len);
}
}
Expand Down
4 changes: 4 additions & 0 deletions cpu/native/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ __attribute__((constructor)) static void startup(int argc, char **argv, char **e
{
_native_init_syscalls();

/* initialize stdio as early as possible */
//early_init();


/* Passing argc, argv, and envp to init_fini handlers is a glibc
* extension. If we are not running glibc, we parse /proc/self/cmdline
* to populate argc and argv by hand */
Expand Down
Loading