Skip to content

Commit

Permalink
Merge branch 'master' into coverity_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
podhrmic committed Aug 11, 2016
2 parents 8b6c1fc + 0f6125f commit 4eb799b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
1 change: 0 additions & 1 deletion conf/Makefile.chibios
Expand Up @@ -80,7 +80,6 @@ ifeq (,$(findstring $(RTOS_DEBUG),0 FALSE))
else
CH_OPT ?= 2 -ggdb
endif

USE_OPT = -std=gnu99 -O$(CH_OPT) \
-falign-functions=16 -fomit-frame-pointer \
-W -Wall \
Expand Down
5 changes: 0 additions & 5 deletions sw/airborne/subsystems/datalink/superbitrf.c
Expand Up @@ -563,11 +563,6 @@ void superbitrf_event(void)
case 5:
superbitrf.state = 7;
break;
// Start receiving
cyrf6936_multi_write(&superbitrf.cyrf6936, cyrf_start_receive, 2);
superbitrf.timer = (get_sys_time_usec() + SUPERBITRF_DATARECVB_TIME) % 0xFFFFFFFF;
superbitrf.state++;
break;
case 6:
// Wait for telemetry data
if (superbitrf.timer < get_sys_time_usec()) {
Expand Down
31 changes: 30 additions & 1 deletion sw/lib/ocaml/cserial.c
Expand Up @@ -35,6 +35,29 @@
#include <caml/alloc.h>
#include <caml/memory.h>

/* MacOS doesn't support higher baudrates (>230400B) */
#ifdef __APPLE__
static int baudrates[] = {
B0,
B50,
B75,
B110,
B134,
B150,
B200,
B300,
B600,
B1200,
B1800,
B2400,
B4800,
B9600,
B19200,
B38400,
B57600,
B115200,
B230400 };
#else /* regular Linux with higher baudrates */
static int baudrates[] = {
B0,
B50,
Expand All @@ -58,6 +81,8 @@ static int baudrates[] = {
B921600,
B1500000,
B3000000 };
#endif /* ifdef __APPLE__ */



/****************************************************************************/
Expand All @@ -68,7 +93,11 @@ value c_init_serial(value device, value speed, value hw_flow_control)
CAMLparam3 (device, speed, hw_flow_control);
struct termios orig_termios, cur_termios;

int br = baudrates[Int_val(speed)];
int br_idx = Int_val(speed);
if (br_idx >= sizeof(baudrates)){
failwith("Baud rate not supported - are you using MacOS? (br_idx out of bounds)");
}
int br = baudrates[br_idx];

int fd = open(String_val(device), O_RDWR|O_NOCTTY|O_NONBLOCK);

Expand Down

0 comments on commit 4eb799b

Please sign in to comment.