git.droids-corp.org
/
protos
/
xbee-avr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add missing #ifndef to protect header files
[protos/xbee-avr.git]
/
cmdline.c
diff --git
a/cmdline.c
b/cmdline.c
index
5eafc1d
..
5745b9c
100644
(file)
--- a/
cmdline.c
+++ b/
cmdline.c
@@
-36,24
+36,23
@@
#include "main.h"
#include "cmdline.h"
#include "main.h"
#include "cmdline.h"
-#include "DualVirtualSerial.h"
+extern const parse_ctx_t PROGMEM main_ctx[];
-/******** See in commands.c for the list of commands. */
-extern parse_pgm_ctx_t main_ctx[];
-
-int usbserial1_dev_send(char c, FILE* f)
+int cmdline_dev_send(char c, FILE* f)
{
{
- CDC_Device_SendByte(&VirtualSerial1_CDC_Interface, (uint8_t)c);
+ (void)f;
+ uart_send(CMDLINE_UART, c);
return 0;
}
return 0;
}
-int
usbserial1
_dev_recv(FILE* f)
+int
cmdline
_dev_recv(FILE* f)
{
int16_t c;
{
int16_t c;
- /* non-blocking ! */
- c = CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);
+
+ (void)f;
+ c = uart_recv_nowait(CMDLINE_UART);
if (c < 0)
return _FDEV_EOF;
if (c < 0)
return _FDEV_EOF;
@@
-61,31
+60,33
@@
int usbserial1_dev_recv(FILE* f)
}
}
-int
usbserial2
_dev_send(char c, FILE* f)
+int
xbee
_dev_send(char c, FILE* f)
{
{
- CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)c);
+ (void)f;
+ uart_send(XBEE_UART, c);
return 0;
}
return 0;
}
-int
usbserial2
_dev_recv(FILE* f)
+int
xbee
_dev_recv(FILE* f)
{
int16_t c;
{
int16_t c;
- /* non-blocking ! */
- c =
CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface
);
+ (void)f;
+ c =
uart_recv_nowait(XBEE_UART
);
if (c < 0)
return _FDEV_EOF;
return c;
}
if (c < 0)
return _FDEV_EOF;
return c;
}
-
static void
valid_buffer(const char *buf, uint8_t size)
{
int8_t ret;
static void
valid_buffer(const char *buf, uint8_t size)
{
int8_t ret;
+ PGM_P ctx = (PGM_P)main_ctx;
- ret = parse(main_ctx, buf);
+ (void)size;
+ ret = parse(ctx, buf);
if (ret == PARSE_AMBIGUOUS)
printf_P(PSTR("Ambiguous command\r\n"));
else if (ret == PARSE_NOMATCH)
if (ret == PARSE_AMBIGUOUS)
printf_P(PSTR("Ambiguous command\r\n"));
else if (ret == PARSE_NOMATCH)
@@
-98,20
+99,21
@@
static int8_t
complete_buffer(const char *buf, char *dstbuf, uint8_t dstsize,
int16_t *state)
{
complete_buffer(const char *buf, char *dstbuf, uint8_t dstsize,
int16_t *state)
{
- return complete(main_ctx, buf, state, dstbuf, dstsize);
+ PGM_P ctx = (PGM_P)main_ctx;
+ return complete(ctx, buf, state, dstbuf, dstsize);
}
static void write_char(char c)
{
}
static void write_char(char c)
{
-
usbserial1
_dev_send(c, NULL);
+
cmdline
_dev_send(c, NULL);
}
void cmdline_init(void)
{
rdline_init(&xbeeboard.rdl, write_char, valid_buffer, complete_buffer);
}
void cmdline_init(void)
{
rdline_init(&xbeeboard.rdl, write_char, valid_buffer, complete_buffer);
- snprintf
(xbeeboard.prompt, sizeof(xbeeboard.prompt), "mainboard > "
);
+ snprintf
_P(xbeeboard.prompt, sizeof(xbeeboard.prompt), PSTR("mainboard > ")
);
}
}
@@
-126,8
+128,10
@@
void emergency(char c)
i++;
else if ( !(i == 1 && c == 'p') )
i = 0;
i++;
else if ( !(i == 1 && c == 'p') )
i = 0;
- if (i == 3)
- bootloader();
+ if (i == 3) {
+ //bootloader();
+ reset();
+ }
}
/* log function, add a command to configure
}
/* log function, add a command to configure
@@
-170,7
+174,7
@@
int cmdline_poll(void)
int8_t ret, same = 0;
int16_t c;
int8_t ret, same = 0;
int16_t c;
- c =
CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface
);
+ c =
cmdline_dev_recv(NULL
);
if (c < 0)
return -1;
if (c < 0)
return -1;