CCSDS Command Link Control Word (CLCW) for spacecraft command
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Port monorepo to latest ocaml-wire (opam pin)

Migrate all consumers to the new wire API:
- wire.c library → wire.3d (Wire_c → Wire_3d)
- Wire.struct_/module_ → Wire.Everparse.struct_/module_
- Wire.Codec: record/|+/seal → Codec.v with Field.v and $
- Wire.bf_uint* → Wire.U8/U16/U16be/U32/U32be
- Wire.UInt32 → Wire.Private.UInt32
- Wire.cases → Wire.lookup, Wire.map now uses labeled args
- Wire.Codec.decode now returns result
- Add wire pin to root.opam.template

+65 -52
+18 -16
c/Clcw.3d
··· 1 - /*++ CCSDS Command Link Control Word (232.1-B-2) --*/ 1 + extern typedef struct _WireCtx WireCtx 2 + 3 + extern unit WireSetU32BE(mutable WireCtx *ctx, UINT32 idx, UINT32BE v) 2 4 3 5 entrypoint 4 - typedef struct _Clcw 6 + typedef struct _Clcw(mutable WireCtx *ctx) 5 7 { 6 - UINT32BE control_word_type : 1; 7 - UINT32BE version : 2; 8 - UINT32BE status : 3; 9 - UINT32BE cop_in_effect : 2; 10 - UINT32BE vcid : 6; 11 - UINT32BE reserved0 : 2; 12 - UINT32BE no_rf_available : 1; 13 - UINT32BE no_bit_lock : 1; 14 - UINT32BE lockout : 1; 15 - UINT32BE wait : 1; 16 - UINT32BE retransmit : 1; 17 - UINT32BE farm_b_counter : 2; 18 - UINT32BE reserved1 : 1; 19 - UINT32BE report_value : 8; 8 + UINT32BE control_word_type : 1 {:act WireSetU32BE(ctx, (UINT32) 0, control_word_type); }; 9 + UINT32BE version : 2 {:act WireSetU32BE(ctx, (UINT32) 1, version); }; 10 + UINT32BE status : 3 {:act WireSetU32BE(ctx, (UINT32) 2, status); }; 11 + UINT32BE cop_in_effect : 2 {:act WireSetU32BE(ctx, (UINT32) 3, cop_in_effect); }; 12 + UINT32BE vcid : 6 {:act WireSetU32BE(ctx, (UINT32) 4, vcid); }; 13 + UINT32BE reserved0 : 2 {:act WireSetU32BE(ctx, (UINT32) 5, reserved0); }; 14 + UINT32BE no_rf_available : 1 {:act WireSetU32BE(ctx, (UINT32) 6, no_rf_available); }; 15 + UINT32BE no_bit_lock : 1 {:act WireSetU32BE(ctx, (UINT32) 7, no_bit_lock); }; 16 + UINT32BE lockout : 1 {:act WireSetU32BE(ctx, (UINT32) 8, lockout); }; 17 + UINT32BE wait : 1 {:act WireSetU32BE(ctx, (UINT32) 9, wait); }; 18 + UINT32BE retransmit : 1 {:act WireSetU32BE(ctx, (UINT32) 10, retransmit); }; 19 + UINT32BE farm_b_counter : 2 {:act WireSetU32BE(ctx, (UINT32) 11, farm_b_counter); }; 20 + UINT32BE reserved1 : 1 {:act WireSetU32BE(ctx, (UINT32) 12, reserved1); }; 21 + UINT32BE report_value : 8 {:act WireSetU32BE(ctx, (UINT32) 13, report_value); }; 20 22 } Clcw; 21 23 22 24
+1 -1
c/dune
··· 6 6 (executable 7 7 (name gen) 8 8 (modules gen) 9 - (libraries clcw wire.c)) 9 + (libraries clcw wire.3d)) 10 10 11 11 (rule 12 12 (mode promote)
+1 -6
c/gen.ml
··· 1 - let () = 2 - Wire_c.main ~package:"clcw" 3 - [ 4 - Wire_c.schema ~name:"Clcw" ~module_:Clcw.module_ 5 - ~wire_size:(Wire.Codec.wire_size Clcw.codec); 6 - ] 1 + let () = Wire_3d.main ~package:"clcw" [ Wire.Everparse.schema Clcw.codec ]
+42 -26
lib/clcw.ml
··· 299 299 300 300 (* Wire Codec *) 301 301 let codec = 302 - let open Wire.Codec in 303 - let bits n = Wire.bits ~width:n Wire.bf_uint32be in 302 + let bits n = Wire.bits ~width:n Wire.U32be in 304 303 let bool = Wire.bool (bits 1) in 305 - let status = Wire.map status_of_int int_of_status (bits 3) in 306 - record "Clcw" (fun cwt ver st cop vcid _r0 no_rf no_bit lck wt rt fb _r1 nr -> 304 + let status = Wire.map ~decode:status_of_int ~encode:int_of_status (bits 3) in 305 + let f_cwt = Wire.Field.v "control_word_type" (bits 1) in 306 + let f_version = Wire.Field.v "version" (bits 2) in 307 + let f_status = Wire.Field.v "status" status in 308 + let f_cop = Wire.Field.v "cop_in_effect" (bits 2) in 309 + let f_vcid = Wire.Field.v "vcid" (bits 6) in 310 + let f_reserved0 = Wire.Field.v "reserved0" (bits 2) in 311 + let f_no_rf = Wire.Field.v "no_rf_available" bool in 312 + let f_no_bit = Wire.Field.v "no_bit_lock" bool in 313 + let f_lockout = Wire.Field.v "lockout" bool in 314 + let f_wait = Wire.Field.v "wait" bool in 315 + let f_retransmit = Wire.Field.v "retransmit" bool in 316 + let f_farm_b = Wire.Field.v "farm_b_counter" (bits 2) in 317 + let f_reserved1 = Wire.Field.v "reserved1" (bits 1) in 318 + let f_report = Wire.Field.v "report_value" (bits 8) in 319 + Wire.Codec.v "Clcw" 320 + (fun cwt ver st cop vcid _r0 no_rf no_bit lck wt rt fb _r1 nr -> 307 321 { 308 322 control_word_type = cwt; 309 323 version = ver; ··· 318 332 farm_b_counter = fb; 319 333 report_value = nr; 320 334 }) 321 - |+ field "control_word_type" (bits 1) (fun t -> t.control_word_type) 322 - |+ field "version" (bits 2) (fun t -> t.version) 323 - |+ field "status" status (fun t -> t.status) 324 - |+ field "cop_in_effect" (bits 2) (fun t -> t.cop_in_effect) 325 - |+ field "vcid" (bits 6) (fun t -> t.vcid) 326 - |+ field "reserved0" (bits 2) (fun _ -> 0) 327 - |+ field "no_rf_available" bool (fun t -> t.no_rf_available) 328 - |+ field "no_bit_lock" bool (fun t -> t.no_bit_lock) 329 - |+ field "lockout" bool (fun t -> t.lockout) 330 - |+ field "wait" bool (fun t -> t.wait) 331 - |+ field "retransmit" bool (fun t -> t.retransmit) 332 - |+ field "farm_b_counter" (bits 2) (fun t -> t.farm_b_counter) 333 - |+ field "reserved1" (bits 1) (fun _ -> 0) 334 - |+ field "report_value" (bits 8) (fun t -> t.report_value) 335 - |> seal 335 + Wire.Codec. 336 + [ 337 + (f_cwt $ fun t -> t.control_word_type); 338 + (f_version $ fun t -> t.version); 339 + (f_status $ fun t -> t.status); 340 + (f_cop $ fun t -> t.cop_in_effect); 341 + (f_vcid $ fun t -> t.vcid); 342 + (f_reserved0 $ fun _ -> 0); 343 + (f_no_rf $ fun t -> t.no_rf_available); 344 + (f_no_bit $ fun t -> t.no_bit_lock); 345 + (f_lockout $ fun t -> t.lockout); 346 + (f_wait $ fun t -> t.wait); 347 + (f_retransmit $ fun t -> t.retransmit); 348 + (f_farm_b $ fun t -> t.farm_b_counter); 349 + (f_reserved1 $ fun _ -> 0); 350 + (f_report $ fun t -> t.report_value); 351 + ] 336 352 337 - let struct_ = Wire.Codec.to_struct codec 353 + let struct_ = Wire.Everparse.struct_of_codec codec 338 354 339 355 let module_ = 340 - Wire.module_ ~doc:"CCSDS Command Link Control Word (232.1-B-2)" "Clcw" 341 - [ Wire.typedef ~entrypoint:true struct_ ] 356 + Wire.Everparse.Raw.module_ ~doc:"CCSDS Command Link Control Word (232.1-B-2)" 357 + [ Wire.Everparse.Raw.typedef ~entrypoint:true struct_ ] 342 358 343 359 (* Parse/Encode via Wire Codec *) 344 360 let wire_size = Wire.Codec.wire_size codec ··· 346 362 let decode_bytes buf = 347 363 if Bytes.length buf < wire_size then 348 364 Error (Wire.Unexpected_eof { expected = wire_size; got = Bytes.length buf }) 349 - else Ok (Wire.Codec.decode codec buf 0) 365 + else Wire.Codec.decode codec buf 0 350 366 351 367 let decode_string s = 352 368 if String.length s < wire_size then 353 369 Error (Wire.Unexpected_eof { expected = wire_size; got = String.length s }) 354 - else Ok (Wire.Codec.decode codec (Bytes.of_string s) 0) 370 + else Wire.Codec.decode codec (Bytes.of_string s) 0 355 371 356 372 let encode_string t = 357 373 let buf = Bytes.create wire_size in ··· 364 380 buf 365 381 366 382 (* FFI Code Generation *) 367 - let c_stubs () = Wire.to_c_stubs [ struct_ ] 368 - let ml_stubs () = Wire.to_ml_stubs [ struct_ ] 383 + let c_stubs () = Wire_stubs.to_c_stubs [ struct_ ] 384 + let ml_stubs () = Wire_stubs.to_ml_stubs [ struct_ ]
+2 -2
lib/clcw.mli
··· 145 145 146 146 val codec : packed Wire.Codec.t 147 147 148 - val struct_ : Wire.struct_ 148 + val struct_ : Wire.Everparse.struct_ 149 149 (** Wire struct descriptor for CLCW. *) 150 150 151 - val module_ : Wire.module_ 151 + val module_ : Wire.Everparse.module_ 152 152 (** Wire module descriptor for CLCW. *) 153 153 154 154 (** {1 Wire Parse/Encode} *)
+1 -1
lib/dune
··· 1 1 (library 2 2 (name clcw) 3 3 (public_name clcw) 4 - (libraries fmt wire)) 4 + (libraries fmt wire wire.stubs))