diff --git a/sw/ground_segment/tmtc/150m.ml b/sw/ground_segment/tmtc/150m.ml deleted file mode 100644 index 5bfeee3bf5..0000000000 --- a/sw/ground_segment/tmtc/150m.ml +++ /dev/null @@ -1,87 +0,0 @@ -(** Code example on the Ivy bus. - Agent which monitors the altitude from the ground and set the A/C in HOME mode - if it reaches 150m. Also displays this altitude and a HOME button to allow the user - to force the HOME mode *) - - -let (//) = Filename.concat - -(* Hard coded id of the A/C *) -let ac_id = "1" - -(* Hard coded index of the pprz_mode variable from the XML setting file *) -let index_pprz_mode = 5 (* From var/include/basic.h *) - -let autopilot_HOME_mode_value = 3 (* From sw/airborne/autopilot.h *) - -(* Build the module to listen telemetry *) -module Tele_Pprz = PprzLink.Messages(struct let name = "telemetry" end) - -(* Build the module to send uplink messages *) -module Datalink_Pprz = PprzLink.Messages(struct let name = "datalink" end) - - - -(******************************* Send the message to the A/C to set it in HOME mode *) -let set_to_HOME = fun () -> - let vs = ["ac_id", PprzLink.String ac_id; - "index", PprzLink.Int index_pprz_mode; - "value", PprzLink.Float (float autopilot_HOME_mode_value)] in - Datalink_Pprz.message_send "dl" "SETTING" vs - - -(******************************* Get GPS message, display the altitude from the SRTM - model, and set to HOME if higher than 150m *) -let get_gps_message = fun label _sender vs -> - (* Extract data from the message *) - let alt_m = PprzLink.int_assoc "alt" vs / 100 - and utm_east = PprzLink.int_assoc "utm_east" vs / 100 - and utm_north = PprzLink.int_assoc "utm_north" vs / 100 - and utm_zone = PprzLink.int_assoc "utm_zone" vs in - - (* Build the geographic position *) - let utm = { Latlong.utm_x = float utm_east; - Latlong.utm_y = float utm_north; - Latlong.utm_zone = utm_zone } in - - (* Get the ground altitude from the SRTM model *) - let srtm_alt_m = Srtm.of_utm utm in - - let height = alt_m - srtm_alt_m in - - (* Display in the label *) - label#set_text (Printf.sprintf "%d" height); - - (* Check if too high *) - if height > 150 then - set_to_HOME () - - -(********************************* Main *********************************************) -let () = - let ivy_bus = Defivybus.default_ivy_bus in - - (** Connect to the Ivy bus *) - Ivy.init "Paparazzi 150m" "READY" (fun _ _ -> ()); - Ivy.start !ivy_bus; - - (** Open the window and a horizontal box container *) - let icon = GdkPixbuf.from_file Env.icon_file in - let window = GWindow.window ~icon ~allow_shrink:true ~title:"GPWS" () in - let hbox = GPack.hbox ~packing:window#add () in - - (* Add a label *) - let label = GMisc.label ~text:"N/A" ~packing:hbox#add () in - - (* And a button *) - let button = GButton.button ~label:"HOME" ~packing:hbox#add () in - - (* Listen GPS message *) - ignore (Tele_Pprz.message_bind "GPS" (get_gps_message label)); - - (* Connect the button to its action *) - ignore (button#connect#clicked ~callback:set_to_HOME); - - (** Display the window and start the main loop *) - window#show (); - GMain.main () diff --git a/sw/ground_segment/tmtc/Makefile b/sw/ground_segment/tmtc/Makefile index 93ba3a312e..fa28606dd0 100644 --- a/sw/ground_segment/tmtc/Makefile +++ b/sw/ground_segment/tmtc/Makefile @@ -37,7 +37,7 @@ XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg pprz.xlib,pprzlink,$(USE_LABELGTK) SERVERCMO = server_globals.cmo aircraft_server.cmo wind.cmo airprox.cmo kml.cmo parse_messages_v1.ml intruder.cmo server.cmo SERVERCMX = $(SERVERCMO:.cmo=.cmx) -all: link server ivy_tcp_aircraft ivy_tcp_controller broadcaster ivy2udp ivy2serial app_server ivy2nmea gpsd2ivy gtk_tools +all: link server ivy_tcp_aircraft ivy_tcp_controller ivy2udp ivy2serial app_server ivy2nmea gpsd2ivy gtk_tools ifeq ($(USE_LABELGTK),lablgtk2) gtk_tools: messages @@ -46,7 +46,7 @@ endif opt: server.opt clean: - $(Q)rm -f link server messages *.bak *~ core *.o .depend *.opt *.out *.cm* ivy_tcp_aircraft ivy_tcp_controller broadcaster ivy2udp ivy2serial ivy_serial_bridge app_server gpsd2ivy c_ivy_client_example_1 c_ivy_client_example_2 ivy2nmea + $(Q)rm -f link server messages *.bak *~ core *.o .depend *.opt *.out *.cm* ivy_tcp_aircraft ivy_tcp_controller ivy2udp ivy2serial ivy_serial_bridge app_server gpsd2ivy c_ivy_client_example_1 c_ivy_client_example_2 ivy2nmea messages : messages.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) @echo OL $@ @@ -75,11 +75,6 @@ ivy_tcp_controller : ivy_tcp_controller.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) $(Q)$(OCAMLC) $(INCLUDES) -o $@ $(LINKPKG) $< -broadcaster : broadcaster.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) - @echo OL $@ - $(Q)$(OCAMLC) $(INCLUDES) -o $@ $(LINKPKG) $< - - ivy2udp : ivy2udp.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) @echo OL $@ $(Q)$(OCAMLC) $(INCLUDES) -o $@ $(LINKPKG) $< @@ -89,10 +84,6 @@ ivy2serial : ivy2serial.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) $(Q)$(OCAMLC) $(INCLUDES) -o $@ $(LINKPKG) $< -150m : 150m.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) - @echo OL $@ - $(Q)$(OCAMLC) $(INCLUDES) -o $@ $(LINKPKG) gtkInit.cmo $< - %.cmo : %.ml @echo OC $< $(Q)$(OCAMLC) $(INCLUDES) $(PKG) -c $< diff --git a/sw/ground_segment/tmtc/app_server.c b/sw/ground_segment/tmtc/app_server.c index 6fc6b0ee5a..a5aa3cae10 100644 --- a/sw/ground_segment/tmtc/app_server.c +++ b/sw/ground_segment/tmtc/app_server.c @@ -230,7 +230,7 @@ int get_wp_data(char* InStr, char* RetBuf) { if ( AcID > 0 ) { //create wp data string char WpStr[MAXWPNUMB*(MAXWPNAMELEN+8)] = ""; - int i = 1; + char i = 1; while ( strlen(DevNames[AcID].AcWp[i].Wp_Name) > 0 ) { //Read & add wp data to return string char wp_str[MAXWPNAMELEN+8] = ""; diff --git a/sw/ground_segment/tmtc/broadcaster.ml b/sw/ground_segment/tmtc/broadcaster.ml deleted file mode 100644 index 9a27d0bf72..0000000000 --- a/sw/ground_segment/tmtc/broadcaster.ml +++ /dev/null @@ -1,57 +0,0 @@ - -open Printf - -let () = - let ivy_bus = ref Defivybus.default_ivy_bus in - - let port = ref 4242 - and ivy_from = ref "DL" - and ivy_to = ref "TM" in - - let options = [ - "-b", Arg.Set_string ivy_bus, (sprintf " Default is %s" !ivy_bus); - "-f", Arg.Set_string ivy_from, (sprintf " Default is %s" !ivy_from); - "-t", Arg.Set_string ivy_to , (sprintf " Default is %s" !ivy_to); - "-p", Arg.Set_int port, (sprintf " Default is %d" !port) - ] in - Arg.parse - options - (fun x -> fprintf stderr "Warning: Discarding '%s'" x) - "Usage: "; - - let handler = fun i o -> - Ivy.init "broadcaster" "READY" (fun _ _ -> ()); - Ivy.start !ivy_bus; - - (* Forward telemetry on Ivy *) - let buffer_size = 256 in - let buffer = Bytes.create buffer_size in - let get_tcp = fun _ -> - begin - try - let n = input i buffer 0 buffer_size in - let data = Bytes.sub buffer 0 n in - - Ivy.send (sprintf "%s %s" !ivy_to (Base64.encode_string (Bytes.to_string data))) - with - exc -> prerr_endline (Printexc.to_string exc) - end; - true in - - let ginput = GMain.Io.channel_of_descr (Unix.descr_of_in_channel i) in - ignore (Glib.Io.add_watch ~cond:[`IN] ~callback:get_tcp ginput); - let hangup = fun _ -> prerr_endline "hangup"; exit 1 in - ignore (Glib.Io.add_watch ~cond:[`HUP] ~callback:hangup ginput); - - (* Forward datalink on Tcp *) - let get_ivy = fun _ args -> - try fprintf o "%s%!" (Base64.decode_string args.(0)) with - exc -> prerr_endline (Printexc.to_string exc) in - ignore (Ivy.bind get_ivy (sprintf "^%s (.*)" !ivy_from)); - - (* Main Loop *) - GMain.main () - in - - let sockaddr = Unix.ADDR_INET (Unix.inet_addr_any, !port) in - Unix.establish_server handler sockaddr; diff --git a/sw/ground_segment/tmtc/modem.ml b/sw/ground_segment/tmtc/modem.ml deleted file mode 100644 index 7f559556a9..0000000000 --- a/sw/ground_segment/tmtc/modem.ml +++ /dev/null @@ -1,120 +0,0 @@ -(* - * Ground harware modem handling - * - * Copyright (C) 2004-2006 CENA/ENAC, Pascal Brisset, Antoine Drouin - * - * This file is part of paparazzi. - * - * paparazzi 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 2, or (at your option) - * any later version. - * - * paparazzi 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 paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - *) - - -open Printf - -module Protocol = struct - (* Header: STX, length of (payload + checksum) *) - (* Payload: tag, data *) - (* Trailer : checksum, ETX *) - - let stx = Char.chr 0x02 - let etx = 0x03 - let index_start = fun buf -> - Bytes.index buf stx - - let payload_length = fun buf start -> - Char.code buf.[start+1] - 1 - - let length = fun buf start -> - let len = Bytes.length buf - start in - if len >= 2 then - Char.code buf.[start+1] + 3 - else - raise Serial.Not_enough - - let checksum = fun msg -> - let l = Bytes.length msg in - let ck_a = ref 0 in - for i = 1 to l - 3 do - ck_a := Char.code msg.[i] lxor !ck_a - done; - !ck_a = Char.code msg.[l-2] && Char.code msg.[l-1] = etx - - let payload = fun msg -> - let l = Bytes.length msg in - assert(l >= 4); - Serial.payload_of_string (Bytes.sub msg 2 (l-4)) - - let packet = fun _payload -> - failwith "Modem.Protocol.packet not implemented" -end - -let msg_data = 0 -let msg_error = 1 -let msg_cd = 2 -let msg_debug = 3 -let msg_valim = 4 - -type status = { - mutable valim : float; - mutable cd : int; - mutable error : int; - mutable debug : int; - mutable nb_byte : int; - mutable nb_msg : int; - mutable nb_err : int; - mutable detected : int -} - -let status = { - valim = 0.; - cd = 0; - error = 0; - debug = 0; - nb_byte = 0; - nb_msg = 0; - nb_err = 0; - detected = 0; -} - (* FIXME *) -let valim = fun x -> float x *. 0.0162863 -. 1.17483 -(* FIXME *) - -let parse_payload = fun payload -> - let payload = Serial.string_of_payload payload in - status.detected <- 1; - let len = Bytes.length payload in - status.nb_byte <- status.nb_byte + len; - status.nb_msg <- status.nb_msg + 1; - let id = Char.code payload.[0] in - if id = msg_data then - Some (Bytes.sub payload 1 (len-1)) - else begin - begin - match id with - | x when x = msg_error -> - status.error <- (Char.code payload.[1]) - | x when x = msg_cd -> - status.cd <- (Char.code payload.[1]) - | x when x = msg_debug -> - status.debug <- (Char.code payload.[1]) - | x when x = msg_valim -> - status.valim <- (valim (Char.code payload.[2] * 0x100 + Char.code payload.[1])); - | _ -> (* Uncorrect id *) - status.nb_err <- status.nb_err + 1 - end; - None - end diff --git a/sw/ground_segment/tmtc/modem.mli b/sw/ground_segment/tmtc/modem.mli deleted file mode 100644 index 6f49862a01..0000000000 --- a/sw/ground_segment/tmtc/modem.mli +++ /dev/null @@ -1,50 +0,0 @@ -(* - * Ground harware modem handling - * - * Copyright (C) 2004 CENA/ENAC, Pascal Brisset, Antoine Drouin - * - * This file is part of paparazzi. - * - * paparazzi 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 2, or (at your option) - * any later version. - * - * paparazzi 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 paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - *) - - -module Protocol : - sig - include Serial.PROTOCOL - val stx : char - val etx : int - val payload_length : string -> int -> int - end - -val parse_payload : Serial.payload -> string option -(* Returns None for modem specific messages (while updating status) *) - -type status = { - mutable valim : float; - mutable cd : int; - mutable error : int; - mutable debug : int; - mutable nb_byte : int; - mutable nb_msg : int; - mutable nb_err : int; - mutable detected : int - } - -val status : status - - diff --git a/sw/lib/ocaml/Makefile b/sw/lib/ocaml/Makefile index acca418c66..2ebf6e7ae3 100644 --- a/sw/lib/ocaml/Makefile +++ b/sw/lib/ocaml/Makefile @@ -34,7 +34,7 @@ PKGCOMMON=pprzlink,xml-light,netclient,nettls-gnutls,glibivy XINCLUDES= XPKGCOMMON=pprzlink,xml-light,glibivy,$(USE_LABELGTK) -SRC = fig.ml debug.ml base64.ml serial.ml ocaml_tools.ml expr_syntax.ml expr_parser.ml expr_lexer.ml extXml.ml env.ml xml2h.ml latlong.ml egm96.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o ubx.ml xmlCom.ml os_calls.ml editAirframe.ml defivybus.ml fp_proc.ml quaternion.ml +SRC = fig.ml debug.ml serial.ml ocaml_tools.ml expr_syntax.ml expr_parser.ml expr_lexer.ml extXml.ml env.ml xml2h.ml latlong.ml egm96.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o ubx.ml xmlCom.ml os_calls.ml editAirframe.ml defivybus.ml fp_proc.ml quaternion.ml SRC += gen_common.ml radio.ml settings.ml module.ml flight_plan.ml autopilot.ml airframe.ml telemetry.ml aircraft.ml CMO = $(SRC:.ml=.cmo) CMX = $(SRC:.ml=.cmx) diff --git a/sw/lib/ocaml/base64.ml b/sw/lib/ocaml/base64.ml deleted file mode 100644 index beed39d891..0000000000 --- a/sw/lib/ocaml/base64.ml +++ /dev/null @@ -1,216 +0,0 @@ -(* - * Downlink protocol (handling messages.xml) - * - * Copyright (c) 2003 Dustin Sallings - * Copyright (C) 2007 ENAC, Pascal Brisset, Antoine Drouin - * - * This file is part of paparazzi. - * - * paparazzi 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 2, or (at your option) - * any later version. - * - * paparazzi 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 paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - *) - -(** Base64 stream encoder/decoder. *) - -(** Exception raised when there's an attempt to encode a chunk incorrectly *) -exception Invalid_encode_chunk of int - - - -(** The character map of all base64 characters *) - -let char_map = [| - 'A'; 'B'; 'C'; 'D'; 'E'; 'F'; 'G'; 'H'; 'I'; 'J'; 'K'; 'L'; 'M'; - 'N'; 'O'; 'P'; 'Q'; 'R'; 'S'; 'T'; 'U'; 'V'; 'W'; 'X'; 'Y'; 'Z'; - 'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm'; - 'n'; 'o'; 'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z'; - '0'; '1'; '2'; '3'; '4'; '5'; '6'; '7'; '8'; '9'; '+'; '/'|] - -(** - Functions for encoding -*) - - -(** Encode a chunk. The chunk is either a 1, 2, or 3 element array. *) - -let encode_chunk chars = - let llength = List.length chars in - if(llength = 0 || llength > 3) then - raise (Invalid_encode_chunk(llength)); - let chunk = Bytes.make 4 '=' in - let a = List.hd chars in - let tmpa = (((Char.code a) land 3) lsl 4) in - Bytes.set chunk 0 char_map.( (Char.code a) lsr 2); - (* Check for another character *) - if (llength < 2) then ( - Bytes.set chunk 1 char_map.(tmpa); - Bytes.to_string chunk; - ) else ( - let b = List.nth chars 1 in - let tmpb = ((Char.code b) lsr 4) in - let tmpa2 = ((Char.code b) land 0x0f) lsl 2 in - Bytes.set chunk 1 char_map.(tmpa lor tmpb); - if (llength < 3) then ( - Bytes.set chunk 2 char_map.(tmpa2); - Bytes.to_string chunk - ) else ( - let c = List.nth chars 2 in - let tmpb2 = ((Char.code c) land 0xc0) lsr 6 in - Bytes.set chunk 2 char_map.(tmpa2 lor tmpb2); - Bytes.set chunk 3 char_map.((Char.code c) land 0x3f); - Bytes.to_string chunk - ) - ) - -(** Stream chunk encoder. - - Use ``Stream.from'' to produce a stream of encoded data from a data stream. *) - -let encode_stream_chunk data_stream cnt = - let stream_empty s = - try - Stream.empty s; - true - with Stream.Failure -> false in - if (stream_empty data_stream) then ( - None - ) else ( - let next = Stream.npeek 3 data_stream in - List.iter (fun x -> Stream.junk data_stream) next; - (* We don't do 76 here as they're in blocks of 4. *) - Some (encode_chunk next ^ - (if (((cnt + 1) mod 19) = 0) then "\013\n" else "")) - ) - -(** Get a Stream of encoded data from the given stream of data. *) - -let encode data_stream = - Stream.from (encode_stream_chunk data_stream) - -(** Base64 encode the string data into a base64 encoded string. *) - -let encode_to_string data_stream = - let buf = Buffer.create 512 in - Stream.iter (fun c -> Buffer.add_string buf c) (encode data_stream); - Buffer.contents buf - -(** Base64 encode a string *) - -let encode_string s = encode_to_string (Stream.of_string s) - -(* ---------------------------------------------------------------------- *) - -(** - Functions for decoding -*) - - -(** Exception raised when there's a problem with the input stream. *) - -exception Invalid_decode_chunk of int - -(** Reverse mapping of character to its index in the char_map *) - -let char_index = - let rv = Array.make 256 (-1) in - for i = 0 to (Array.length char_map - 1) do - let c = char_map.(i) in - Array.set rv (Char.code c) i - done; - rv - -(** Is the given character a valid base64 character? *) - -let is_base64_char c = - char_index.(Char.code c) != -1 - -(** Decode a chunk represented as a list of characters. The chunk must be 2, 3, or 4 elements large. *) - -let decode_chunk chars = - let rv = Buffer.create 3 in - let fchars = (List.filter (fun c -> c != '=') chars) in - let packer = List.fold_left (fun o x -> (o lsl 6) lor x) 0 - (List.map (fun c -> char_index.(Char.code c)) fchars) in - ( - match List.length fchars with - | 4 -> - Buffer.add_char rv (Char.chr (0xff land (packer lsr 16))); - Buffer.add_char rv (Char.chr (0xff land (packer lsr 8))); - Buffer.add_char rv (Char.chr (0xff land packer)); - | 3 -> - Buffer.add_char rv (Char.chr (0xff land ((packer lsl 6) lsr 16))); - Buffer.add_char rv (Char.chr (0xff land ((packer lsl 6) lsr 8))); - | 2 -> - Buffer.add_char rv (Char.chr (0xff land ((packer lsl 12) lsr 16))); - | _ -> raise (Invalid_decode_chunk(List.length fchars)); - ); - Buffer.contents rv - -(** Decode a stream of base64 characters into a stream of 3 or fewer byte strings. *) - -let decode data_stream = - let rec find_next x = - try - Stream.empty data_stream; - None - with Stream.Failure -> ( - let rv = Stream.next data_stream in - if (is_base64_char(rv)) then - Some rv - else (find_next x) - ) in - let clean_stream = Stream.from find_next in - let get_block x = - try - let chunk = Stream.npeek 4 clean_stream in - List.iter (fun x -> Stream.junk clean_stream) chunk; - match chunk with - [] -> None - | _ -> Some(decode_chunk chunk) - with Stream.Failure -> None in - Stream.from get_block - -(** Base64 decode the stream of base64 encoded data into a string. *) - -let decode_to_string data_stream = - let buf = Buffer.create 512 in - Stream.iter (fun c -> Buffer.add_string buf c) (decode data_stream); - Buffer.contents buf - -(** Base64 decode a string to a string *) - -let decode_string s = decode_to_string (Stream.of_string s) - -(** - Functions for testing -*) - - -(** Simple test function. *) - -let test() = - let wordlist = ["A";"AB";"ABC";"Dustin";Bytes.to_string (Bytes.create 128)] in - print_endline("String:"); - List.iter (fun x -> print_endline(encode_string x)) - wordlist; - print_endline("Stream:"); - List.iter (fun x -> - Stream.iter print_string (encode (Stream.of_string x)); - print_newline() - ) wordlist; - print_endline("Decode:"); - List.iter (fun x -> print_endline(decode_string (encode_string x))) - wordlist diff --git a/sw/lib/ocaml/base64.mli b/sw/lib/ocaml/base64.mli deleted file mode 100644 index 0c05651536..0000000000 --- a/sw/lib/ocaml/base64.mli +++ /dev/null @@ -1,30 +0,0 @@ -(* - * Downlink protocol (handling messages.xml) - * - * Copyright (c) 2003 Dustin Sallings - * Copyright (C) 2007 ENAC, Pascal Brisset, Antoine Drouin - * - * This file is part of paparazzi. - * - * paparazzi 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 2, or (at your option) - * any later version. - * - * paparazzi 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 paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - *) - -exception Invalid_encode_chunk of int -exception Invalid_decode_chunk of int - -val encode_string : string -> string -val decode_string : string -> string diff --git a/sw/lib/ocaml/cserial.c b/sw/lib/ocaml/cserial.c index 2ece9261d9..e1ddd324e5 100644 --- a/sw/lib/ocaml/cserial.c +++ b/sw/lib/ocaml/cserial.c @@ -95,15 +95,15 @@ value c_init_serial(value device, value speed, value hw_flow_control) 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)"); + caml_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); - if (fd == -1) failwith("opening modem serial device : fd < 0"); + if (fd == -1) caml_failwith("opening modem serial device : fd < 0"); - if (tcgetattr(fd, &orig_termios)) failwith("getting modem serial device attr"); + if (tcgetattr(fd, &orig_termios)) caml_failwith("getting modem serial device attr"); cur_termios = orig_termios; /* input modes - turn off input processing */ @@ -129,9 +129,9 @@ value c_init_serial(value device, value speed, value hw_flow_control) cur_termios.c_lflag &= ~(ISIG|ICANON|IEXTEN|ECHO|FLUSHO|PENDIN); cur_termios.c_lflag |= NOFLSH; - if (cfsetspeed(&cur_termios, br)) failwith("setting modem serial device speed"); + if (cfsetspeed(&cur_termios, br)) caml_failwith("setting modem serial device speed"); - if (tcsetattr(fd, TCSADRAIN, &cur_termios)) failwith("setting modem serial device attr"); + if (tcsetattr(fd, TCSADRAIN, &cur_termios)) caml_failwith("setting modem serial device attr"); CAMLreturn (Val_int(fd)); } @@ -160,7 +160,7 @@ value c_serial_set_baudrate(value val_fd, value speed) int fd = Int_val(val_fd); if (tcgetattr(fd, &tio) < 0) { - failwith("tcgetattr"); + caml_failwith("tcgetattr"); } tio.c_iflag = 0; tio.c_oflag = 0; @@ -175,7 +175,7 @@ value c_serial_set_baudrate(value val_fd, value speed) cfsetispeed(&tio, br); cfsetospeed(&tio, br); if (tcsetattr(fd, TCSANOW | TCSAFLUSH, &tio) < 0) { - failwith("tcsetattr"); + caml_failwith("tcsetattr"); } CAMLreturn (Val_unit); }