mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge branch 'master' of ssh://ukleos.des-mesh.net/home/git/ukleos
Conflicts: sys/Jamfile
This commit is contained in:
commit
c8315c4270
2
Jamfile
2
Jamfile
@ -60,6 +60,8 @@ LOCATE on $(TARGET:S=.hex) = bin ;
|
||||
Doc doc ; # build the documentation
|
||||
Flash flash : $(TARGET:S=.hex) ;
|
||||
Reset reset ;
|
||||
Terminal term ;
|
||||
Test test : all ;
|
||||
|
||||
Debug debug : $(TARGET) ;
|
||||
ListModules listmodules ;
|
||||
|
2
Jamrules
2
Jamrules
@ -39,6 +39,8 @@ SUFFIX ?= "" ; # must be at least "" !!!
|
||||
TARGET = "$(BOARD)-$(PROJECT)$(SUFFIX)$(SUFEXE)" ; # main target binary
|
||||
OPENOCD_IF ?= olimex-jtag-tiny-a ;
|
||||
|
||||
TERMINAL ?= board/msba2/tools/bin/pseudoterm ;
|
||||
|
||||
if $(NT) || $(OS) = CYGWIN {
|
||||
PORT = $(PORT:E=1) ;
|
||||
} else {
|
||||
|
@ -172,12 +172,30 @@ actions Flash
|
||||
$(FLASHER) $(FLASHFLAGS) $(>)
|
||||
}
|
||||
|
||||
#
|
||||
# Run all tests for active project
|
||||
rule Test
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
}
|
||||
actions Test
|
||||
{
|
||||
for tst in projects/$(PROJECT)/tests/*; do $tst; done
|
||||
}
|
||||
|
||||
# Reset connected sensor node
|
||||
actions Reset
|
||||
{
|
||||
$(RESET) > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# run a terminal
|
||||
#
|
||||
actions Terminal
|
||||
{
|
||||
$(TERMINAL) $(TERMOPTS) $(PORT)
|
||||
}
|
||||
|
||||
#
|
||||
# Run debug server
|
||||
rule Debug
|
||||
|
@ -29,5 +29,5 @@ CPU = lpc2387 ;
|
||||
|
||||
HDRS += [ FPath $(TOP) board $(BOARD) drivers include ] ;
|
||||
|
||||
FLASHER = $(POSIXSHELL) $(TOP)/board/msba2/tools/flashutil.sh ;
|
||||
FLASHFLAGS = --basedir $(TOP)/board/msba2/tools --id "MSB-A2" --ports "$(PORT)" ;
|
||||
FLASHER ?= $(POSIXSHELL) $(TOP)/board/msba2/tools/flashutil.sh ;
|
||||
FLASHFLAGS ?= --basedir $(TOP)/board/msba2/tools --id "MSB-A2" --ports "$(PORT)" ;
|
||||
|
@ -25,7 +25,7 @@ and the mailinglist (subscription via web site)
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @ingroup pttu
|
||||
* @ingroup msba2
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -3,4 +3,5 @@ SubDir TOP board msba2 drivers ;
|
||||
Module board_cc1100 : msba2-cc1100.c ;
|
||||
Module board_hal : msba2-hal.c ;
|
||||
Module board_ltc4150 : msba2-ltc4150.c : gpioint ;
|
||||
Module board_common : msba2-uart0.c msba2-uart0_thread.c : ringbuffer ;
|
||||
Module board_common : msba2-uart0.c : ringbuffer ;
|
||||
Module board_uart : msba2-uart0_thread.c : chardev_thread ringbuffer ;
|
||||
|
@ -36,9 +36,7 @@ and the mailinglist (subscription via web site)
|
||||
#include "lpc23xx.h"
|
||||
#include "VIC.h"
|
||||
|
||||
#include <msg.h>
|
||||
#include <ringbuffer.h>
|
||||
#include "uart0.h"
|
||||
#include <board_uart0.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
@ -67,9 +65,6 @@ static volatile unsigned int fifo = 0;
|
||||
|
||||
static volatile toprint* actual = NULL;
|
||||
|
||||
int uart0_handler_pid = 0;
|
||||
extern ringbuffer uart0_ringbuffer;
|
||||
|
||||
static inline void enqueue(void) {
|
||||
queue_items++;
|
||||
queue_tail++;
|
||||
@ -109,14 +104,6 @@ int uart_active(void){
|
||||
return (running || fifo);
|
||||
}
|
||||
|
||||
static void notify_handler() {
|
||||
if (uart0_handler_pid) {
|
||||
msg m;
|
||||
m.type = 0;
|
||||
msg_send_int(&m, uart0_handler_pid);
|
||||
}
|
||||
}
|
||||
|
||||
void stdio_flush(void)
|
||||
{
|
||||
U0IER &= ~BIT1; // disable THRE interrupt
|
||||
@ -142,14 +129,16 @@ void UART0_IRQHandler(void)
|
||||
|
||||
case UIIR_CTI_INT: // Character Timeout Indicator
|
||||
case UIIR_RDA_INT: // Receive Data Available
|
||||
do {
|
||||
int c = U0RBR;
|
||||
rb_add_element(&uart0_ringbuffer, c);
|
||||
} while (U0LSR & ULSR_RDR);
|
||||
|
||||
notify_handler();
|
||||
#ifdef MODULE_UART0
|
||||
if (uart0_handler_pid) {
|
||||
do {
|
||||
int c = U0RBR;
|
||||
uart0_handle_incoming(c);
|
||||
} while (U0LSR & ULSR_RDR);
|
||||
uart0_notify_thread();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
U0LSR;
|
||||
U0RBR;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
void* _malloc(size_t size);
|
||||
void* _realloc(void *ptr, size_t size);
|
||||
void _free (void* ptr);
|
||||
|
||||
/** @} */
|
||||
|
@ -13,6 +13,8 @@
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Creates a new thread.
|
||||
|
@ -35,6 +35,13 @@ void *_malloc(size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
void *_realloc(void *ptr, size_t size) {
|
||||
void* newptr = _malloc(size);
|
||||
memcpy(newptr, ptr, size);
|
||||
free(ptr);
|
||||
return newptr;
|
||||
}
|
||||
|
||||
void _free(void* ptr) {
|
||||
DEBUG("_free(): block at 0x%X lost.\n", (unsigned int)ptr);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "oneway_malloc.h"
|
||||
|
||||
#define malloc _malloc
|
||||
#define realloc _realloc
|
||||
#define free _free
|
||||
|
||||
#endif /* __MALLOC_H */
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
set timeout 5
|
||||
|
||||
spawn board/msba2/tools/bin/pseudoterm $env(PORT)
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
exec jam reset
|
||||
|
||||
|
5
projects/hello-world/tests/hello-world.py
Normal file → Executable file
5
projects/hello-world/tests/hello-world.py
Normal file → Executable file
@ -1,8 +1,11 @@
|
||||
#!/usr/bin/python
|
||||
import pexpect
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
child = pexpect.spawn ("board/msba2/tools/bin/pseudoterm %s" % os.environ["PORT"])
|
||||
# testing hello world
|
||||
|
||||
child = pexpect.spawn ("pseudoterm %s" % os.environ["PORT"])
|
||||
|
||||
null = open('/dev/null', 'wb')
|
||||
subprocess.call(['jam', 'reset'], stdout=null)
|
||||
|
@ -6,6 +6,6 @@
|
||||
|
||||
SubDir TOP projects test_shell ;
|
||||
|
||||
Module test_shell : test_shell.c : shell posix_io ;
|
||||
Module test_shell : test_shell.c : shell posix_io ps uart0 ;
|
||||
|
||||
UseModule test_shell ;
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <uart0.h>
|
||||
#include <posix_io.h>
|
||||
#include <shell.h>
|
||||
#include <board_uart0.h>
|
||||
|
||||
void print_teststart(char* str) {
|
||||
printf("[TEST_START]\n");
|
||||
@ -18,28 +18,34 @@ void print_testend(char* str) {
|
||||
printf("[TEST_END]\n");
|
||||
}
|
||||
|
||||
//extern int uart0_init();
|
||||
//extern int uart0_handler_pid;
|
||||
|
||||
int shell_readc() {
|
||||
char c = 0;
|
||||
posix_read(uart0_handler_pid, &c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
void shell_putchar(int c) {
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
const shell_command_t shell_commands[] = {
|
||||
{"start_test", print_teststart},
|
||||
{"end_test", print_testend},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
//printf("Moin. build on %s %s SVN-Revision: %s\n", kernel_builddate, kernel_buildtime, kernel_svnrevision);
|
||||
printf("test_shell.\n");
|
||||
|
||||
uart0_init();
|
||||
board_uart0_init();
|
||||
|
||||
posix_open(uart0_handler_pid, 0);
|
||||
|
||||
shell_t shell;
|
||||
shell_init(&shell, shell_readc);
|
||||
|
||||
shell_register_cmd(&shell, "start_test", print_teststart);
|
||||
shell_register_cmd(&shell, "end_test", print_testend);
|
||||
shell_init(&shell, shell_readc, shell_putchar);
|
||||
|
||||
shell.command_list = shell_commands;
|
||||
|
||||
shell_run(&shell);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
set timeout 5
|
||||
|
||||
spawn board/msba2/tools/bin/pseudoterm $env(PORT)
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
set timeout 1
|
||||
|
||||
spawn board/msba2/tools/bin/pseudoterm $env(PORT)
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
sleep 1
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 1
|
||||
set timeout 2
|
||||
|
||||
spawn board/msba2/tools/bin/pseudoterm $env(PORT)
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
sleep 1
|
||||
|
||||
@ -13,7 +13,7 @@ expect {
|
||||
|
||||
send "some_definately_unknown_command\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
"shell: command "some_definately_unknown_command" not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,17 @@ SubDir TOP sys ;
|
||||
|
||||
Module swtimer : swtimer.c : hwtimer ;
|
||||
Module posix_io : posix_io.c ;
|
||||
<<<<<<< HEAD
|
||||
Module shell : shell.c : hashtable hash_string ;
|
||||
Module ps : ps.c ;
|
||||
=======
|
||||
>>>>>>> 355988f8cfa6d2d86fbdb7993fa6823943ca23c6
|
||||
|
||||
Module auto_init : auto_init.c ;
|
||||
|
||||
Module chardev_thread : chardev_thread.c : ringbuffer ;
|
||||
Module uart0 : uart0.c : ringbuffer chardev_thread ;
|
||||
|
||||
SubInclude TOP sys net ;
|
||||
SubInclude TOP sys lib ;
|
||||
SubInclude TOP sys shell ;
|
||||
|
@ -1,36 +1,22 @@
|
||||
#include <thread.h>
|
||||
#include <kernel.h>
|
||||
#include <msg.h>
|
||||
#include <board.h>
|
||||
#include <ringbuffer.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <irq.h>
|
||||
#include <posix_io.h>
|
||||
#include "uart0.h"
|
||||
|
||||
//#define ENABLE_DEBUG
|
||||
#include <debug.h>
|
||||
|
||||
static char buffer[UART0_BUFSIZE];
|
||||
ringbuffer uart0_ringbuffer;
|
||||
|
||||
static void uart0_loop();
|
||||
|
||||
void uart0_init() {
|
||||
ringbuffer_init(&uart0_ringbuffer, buffer, UART0_BUFSIZE);
|
||||
int pid = thread_create(KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_STACKTEST, uart0_loop, "uart0");
|
||||
uart0_handler_pid = pid;
|
||||
puts("uart0_init() [OK]");
|
||||
}
|
||||
|
||||
static int min(int a, int b) {
|
||||
if (b>a) return a;
|
||||
else return b;
|
||||
}
|
||||
|
||||
static void uart0_loop() {
|
||||
void chardev_loop(ringbuffer *rb) {
|
||||
msg m;
|
||||
|
||||
int pid = thread_getpid();
|
||||
@ -80,11 +66,11 @@ static void uart0_loop() {
|
||||
}
|
||||
}
|
||||
|
||||
if (uart0_ringbuffer.avail && (r != NULL)) {
|
||||
if (rb->avail && (r != NULL)) {
|
||||
int state = disableIRQ();
|
||||
int nbytes = min(r->nbytes, uart0_ringbuffer.avail);
|
||||
int nbytes = min(r->nbytes, rb->avail);
|
||||
DEBUG("uart0_thread: sending %i bytes to pid %i\n", nbytes, reader_pid);
|
||||
rb_get_elements(&uart0_ringbuffer, r->buffer, nbytes);
|
||||
rb_get_elements(rb, r->buffer, nbytes);
|
||||
r->nbytes = nbytes;
|
||||
|
||||
m.sender_pid = reader_pid;
|
10
sys/include/board_uart0.h
Normal file
10
sys/include/board_uart0.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __BOARD_UART0_H
|
||||
#define __BOARD_UART0_H
|
||||
|
||||
extern int uart0_handler_pid;
|
||||
|
||||
void board_uart0_init();
|
||||
void uart0_handle_incoming(int c);
|
||||
void uart0_notify_thread();
|
||||
|
||||
#endif /* __BOARD_UART0_H */
|
8
sys/include/chardev_thread.h
Normal file
8
sys/include/chardev_thread.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __CHARDEV_THREAD_H
|
||||
#define __CHARDEV_THREAD_H
|
||||
|
||||
#include <ringbuffer.h>
|
||||
|
||||
void chardev_loop(ringbuffer *rb);
|
||||
|
||||
#endif /* __CHARDEV_THREAD_H */
|
@ -24,25 +24,31 @@ and the mailinglist (subscription via web site)
|
||||
scatterweb@lists.spline.inf.fu-berlin.de
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __SIMPLE_SHELL_H
|
||||
#define __SIMPLE_SHELL_H
|
||||
#ifndef __SHELL_H
|
||||
#define __SHELL_H
|
||||
|
||||
/**
|
||||
* @defgroup shell Simple Shell Interpreter
|
||||
* @ingroup feuerware
|
||||
*/
|
||||
|
||||
#include "hashtable.h"
|
||||
//#include "hashtable.h"
|
||||
|
||||
typedef struct shell_commant_t {
|
||||
char* name;
|
||||
void (*handler)(char*);
|
||||
} shell_command_t;
|
||||
|
||||
typedef struct shell_t {
|
||||
struct hashtable *h;
|
||||
const shell_command_t *command_list;
|
||||
int (*readchar)(void);
|
||||
void (*put_char)(int);
|
||||
} shell_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize a shell object
|
||||
*/
|
||||
void shell_init(shell_t *shell, int(*readchar)(void));
|
||||
void shell_init(shell_t *shell, int(*read_char)(void), void (*put_char)(int));
|
||||
|
||||
/**
|
||||
* @brief Register a new command handler for a shell.
|
||||
@ -50,11 +56,14 @@ void shell_init(shell_t *shell, int(*readchar)(void));
|
||||
* @param name Name of the command to register.
|
||||
* @param handler Function pointer to handler that takes the complete command line as parameter.
|
||||
*/
|
||||
void shell_register_cmd(shell_t *shell, char* name, void (*handler)(char* args));
|
||||
//void shell_register_cmd(shell_t *shell, char* name, void (*handler)(char* args));
|
||||
|
||||
/**
|
||||
* @brief Endless loop that waits for command and executes handler.
|
||||
*/
|
||||
void shell_run(shell_t *shell);
|
||||
|
||||
#endif /* __SIMPLE_SHELL_H */
|
||||
|
||||
void shell_auto_init(shell_t *shell);
|
||||
|
||||
#endif /* __SHELL_H */
|
||||
|
34
sys/shell/Jamfile
Normal file
34
sys/shell/Jamfile
Normal file
@ -0,0 +1,34 @@
|
||||
# ******************************************************************************
|
||||
# Copyright 2009, Freie Universitaet Berlin (FUB). All rights reserved.
|
||||
#
|
||||
# These sources were developed at the Freie Universitaet Berlin, Computer
|
||||
# Systems and Telematics group (http://cst.mi.fu-berlin.de).
|
||||
# ------------------------------------------------------------------------------
|
||||
# This file is part of FeuerWare.
|
||||
#
|
||||
# This program 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 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# FeuerWare 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
|
||||
# this program. If not, see http://www.gnu.org/licenses/ .
|
||||
# ------------------------------------------------------------------------------
|
||||
# For further information and questions please use the web site
|
||||
# http://scatterweb.mi.fu-berlin.de
|
||||
# and the mailinglist (subscription via web site)
|
||||
# scatterweb@lists.spline.inf.fu-berlin.de
|
||||
# ******************************************************************************
|
||||
# $Id$
|
||||
|
||||
SubDir TOP sys shell ;
|
||||
|
||||
Module shell : shell.c ;
|
||||
Module shell_commands : shell_commands.c : shell ;
|
||||
|
||||
Module ps : ps.c ;
|
||||
|
@ -46,9 +46,21 @@ and the mailinglist (subscription via web site)
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <hash_string.h>
|
||||
#include <shell.h>
|
||||
|
||||
static void(*find_handler(const shell_command_t *command_list, char *command))(char*) {
|
||||
const shell_command_t *entry = command_list;
|
||||
|
||||
while(entry->name != NULL) {
|
||||
if ( strcmp(entry->name, command) == 0) {
|
||||
return entry->handler;
|
||||
} else {
|
||||
command_list++;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void handle_input_line(shell_t *shell, char* line) {
|
||||
char* saveptr;
|
||||
char* command = strtok_r(line, " ", &saveptr);
|
||||
@ -56,7 +68,7 @@ static void handle_input_line(shell_t *shell, char* line) {
|
||||
void (*handler)(char*) = NULL;
|
||||
|
||||
if (command) {
|
||||
handler = hashtable_search(shell->h, command);
|
||||
handler = find_handler(shell->command_list, command);
|
||||
if (handler) {
|
||||
handler(line);
|
||||
} else {
|
||||
@ -77,8 +89,7 @@ int readline(shell_t *shell, char* buf, int size) {
|
||||
}
|
||||
|
||||
c = shell->readchar();
|
||||
|
||||
write(STDOUT_FILENO, &c, 1);
|
||||
shell->put_char(c);
|
||||
|
||||
if (c == 13) continue;
|
||||
|
||||
@ -95,7 +106,7 @@ void shell_run(shell_t *shell) {
|
||||
char line_buf[255];
|
||||
|
||||
while(1) {
|
||||
write(STDOUT_FILENO, ">", 1);
|
||||
shell->put_char('>');
|
||||
int res = readline(shell, line_buf, sizeof(line_buf));
|
||||
if (! res ) {
|
||||
handle_input_line(shell, strdup(line_buf));
|
||||
@ -103,13 +114,9 @@ void shell_run(shell_t *shell) {
|
||||
}
|
||||
}
|
||||
|
||||
void shell_init(shell_t *shell, int(*readchar)(void)) {
|
||||
shell->h = create_hashtable(16, (unsigned int (*)(void*)) hash_string, (int (*) (void*,void*)) cmp_string);
|
||||
void shell_init(shell_t *shell, int(*readchar)(void), void(*put_char)(int)) {
|
||||
shell->readchar = readchar;
|
||||
}
|
||||
|
||||
void shell_register_cmd(shell_t *shell, char* name, void (*handler)(char* args)) {
|
||||
hashtable_insert(shell->h, name, handler);
|
||||
shell->put_char = put_char;
|
||||
}
|
||||
|
||||
/** @} */
|
9
sys/shell/shell_commands.c
Normal file
9
sys/shell/shell_commands.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <shell.h>
|
||||
|
||||
const shell_command_t _shell_command_list[] = {
|
||||
#ifdef MODULE_PS
|
||||
{"ps", ps_handler},
|
||||
#endif
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
35
sys/uart0.c
Normal file
35
sys/uart0.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <chardev_thread.h>
|
||||
#include <ringbuffer.h>
|
||||
#include <stdio.h>
|
||||
#include <thread.h>
|
||||
#include <msg.h>
|
||||
|
||||
#include <board_uart0.h>
|
||||
|
||||
#define UART0_BUFSIZE 32
|
||||
|
||||
ringbuffer uart0_ringbuffer;
|
||||
int uart0_handler_pid;
|
||||
|
||||
static char buffer[UART0_BUFSIZE];
|
||||
|
||||
static void uart0_loop() {
|
||||
chardev_loop(&uart0_ringbuffer);
|
||||
}
|
||||
|
||||
void board_uart0_init() {
|
||||
ringbuffer_init(&uart0_ringbuffer, buffer, UART0_BUFSIZE);
|
||||
int pid = thread_create(KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_STACKTEST, uart0_loop, "uart0");
|
||||
uart0_handler_pid = pid;
|
||||
puts("uart0_init() [OK]");
|
||||
}
|
||||
|
||||
void uart0_handle_incoming(int c) {
|
||||
rb_add_element(&uart0_ringbuffer, c);
|
||||
}
|
||||
|
||||
void uart0_notify_thread() {
|
||||
msg m;
|
||||
m.type = 0;
|
||||
msg_send_int(&m, uart0_handler_pid);
|
||||
}
|
Loading…
Reference in New Issue
Block a user