1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195
/* automatically generated by rust-bindgen */ pub const TASK_PRIORITY_DEFAULT: u32 = 8; pub const TASK_STACK_DEPTH_DEFAULT: u32 = 8192; pub const controller_id_e_t_E_CONTROLLER_MASTER: controller_id_e_t = 0; pub const controller_id_e_t_E_CONTROLLER_PARTNER: controller_id_e_t = 1; pub type controller_id_e_t = u32; pub const controller_analog_e_t_E_CONTROLLER_ANALOG_LEFT_X: controller_analog_e_t = 0; pub const controller_analog_e_t_E_CONTROLLER_ANALOG_LEFT_Y: controller_analog_e_t = 1; pub const controller_analog_e_t_E_CONTROLLER_ANALOG_RIGHT_X: controller_analog_e_t = 2; pub const controller_analog_e_t_E_CONTROLLER_ANALOG_RIGHT_Y: controller_analog_e_t = 3; pub type controller_analog_e_t = u32; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_L1: controller_digital_e_t = 6; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_L2: controller_digital_e_t = 7; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_R1: controller_digital_e_t = 8; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_R2: controller_digital_e_t = 9; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_UP: controller_digital_e_t = 10; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_DOWN: controller_digital_e_t = 11; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_LEFT: controller_digital_e_t = 12; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_RIGHT: controller_digital_e_t = 13; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_X: controller_digital_e_t = 14; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_B: controller_digital_e_t = 15; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_Y: controller_digital_e_t = 16; pub const controller_digital_e_t_E_CONTROLLER_DIGITAL_A: controller_digital_e_t = 17; pub type controller_digital_e_t = u32; extern "C" { /// Gets the value of an analog channel (joystick) on a controller. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - A value other than E_CONTROLLER_MASTER or E_CONTROLLER_PARTNER /// is /// given. /// EACCES - Another resource is currently trying to access the controller /// port. /// /// \param id /// The ID of the controller (e.g. the master or partner controller). /// Must be one of CONTROLLER_MASTER or CONTROLLER_PARTNER /// \param channel /// The analog channel to get. /// Must be one of ANALOG_LEFT_X, ANALOG_LEFT_Y, ANALOG_RIGHT_X, /// ANALOG_RIGHT_Y /// /// \return The current reading of the analog channel: [-127, 127]. /// If the controller was not connected, then 0 is returned pub fn controller_get_analog(id: controller_id_e_t, channel: controller_analog_e_t) -> i32; } extern "C" { /// Checks if a digital channel (button) on the controller is currently /// pressed. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - A value other than E_CONTROLLER_MASTER or E_CONTROLLER_PARTNER /// is /// given. /// EACCES - Another resource is currently trying to access the controller /// port. /// /// \param id /// The ID of the controller (e.g. the master or partner controller). /// Must be one of CONTROLLER_MASTER or CONTROLLER_PARTNER /// \param button /// The button to read. /// Must be one of DIGITAL_{RIGHT,DOWN,LEFT,UP,A,B,Y,X,R1,R2,L1,L2} /// /// \return 1 if the button on the controller is pressed. /// If the controller was not connected, then 0 is returned pub fn controller_get_digital(id: controller_id_e_t, button: controller_digital_e_t) -> i32; } extern "C" { /// Sets the voltage for the motor from -127 to 127. /// /// This is designed to map easily to the input from the controller's analog /// stick for simple opcontrol use. The actual behavior of the motor is /// analogous /// to use of motor_move_voltage(), or motorSet() from the PROS 2 API. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param voltage /// The new motor voltage from -127 to 127 /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_move(port: u8, voltage: i32) -> i32; } extern "C" { /// Sets the target absolute position for the motor to move to. /// /// This movement is relative to the position of the motor when initialized /// or /// the position when it was most recently reset with /// motor_set_zero_position(). /// /// \note This function simply sets the target for the motor, it does not /// block /// program execution until the movement finishes. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param position /// The absolute position to move to in the motor's encoder units /// \param velocity /// The maximum allowable velocity for the movement in RPM /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_move_absolute(port: u8, position: f64, velocity: i32) -> i32; } extern "C" { /// Sets the relative target position for the motor to move to. /// /// This movement is relative to the current position of the motor as given /// in /// motor_get_position(). Providing 10.0 as the position parameter would /// result /// in the motor moving clockwise 10 units, no matter what the current /// position /// is. /// /// \note This function simply sets the target for the motor, it does not /// block /// program execution until the movement finishes. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param position /// The relative position to move to in the motor's encoder units /// \param velocity /// The maximum allowable velocity for the movement in RPM /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_move_relative(port: u8, position: f64, velocity: i32) -> i32; } extern "C" { /// Sets the velocity for the motor. /// /// This velocity corresponds to different actual speeds depending on the /// gearset /// used for the motor. This results in a range of +-100 for /// E_MOTOR_GEARSET_36, /// +-200 for E_MOTOR_GEARSET_18, and +-600 for E_MOTOR_GEARSET_6. The /// velocity /// is held with PID to ensure consistent speed, as opposed to setting the /// motor's voltage. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param velocity /// The new motor velocity from +-100, +-200, or +-600 depending on /// the /// motor's gearset /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_move_velocity(port: u8, velocity: i32) -> i32; } extern "C" { /// Sets the output voltage for the motor from -12000 to 12000 in millivolts /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param voltage /// The new voltage value from -12000 to 12000 /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_move_voltage(port: u8, voltage: i32) -> i32; } extern "C" { /// Changes the output velocity for a profiled movement (motor_move_absolute /// or /// motor_move_relative). This will have no effect if the motor is not /// following /// a profiled movement. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param velocity /// The new motor velocity from +-100, +-200, or +-600 depending on /// the /// motor's gearset /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_modify_profiled_velocity(port: u8, velocity: i32) -> i32; } extern "C" { /// Gets the target position set for the motor by the user. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The target position in its encoder units or PROS_ERR_F if the /// operation failed, setting errno. pub fn motor_get_target_position(port: u8) -> f64; } extern "C" { /// Gets the velocity commanded to the motor by the user. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The commanded motor velocity from +-100, +-200, or +-600, or /// PROS_ERR /// if the operation failed, setting errno. pub fn motor_get_target_velocity(port: u8) -> i32; } extern "C" { /// Gets the actual velocity of the motor. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's actual velocity in RPM or PROS_ERR_F if the /// operation /// failed, setting errno. pub fn motor_get_actual_velocity(port: u8) -> f64; } extern "C" { /// Gets the current drawn by the motor in mA. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's current in mA or PROS_ERR if the operation failed, /// setting errno. pub fn motor_get_current_draw(port: u8) -> i32; } extern "C" { /// Gets the direction of movement for the motor. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return 1 for moving in the positive direction, -1 for moving in the /// negative direction, or PROS_ERR if the operation failed, setting errno. pub fn motor_get_direction(port: u8) -> i32; } extern "C" { /// Gets the efficiency of the motor in percent. /// /// An efficiency of 100% means that the motor is moving electrically while /// drawing no electrical power, and an efficiency of 0% means that the /// motor /// is drawing power but not moving. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's efficiency in percent or PROS_ERR_F if the operation /// failed, setting errno. pub fn motor_get_efficiency(port: u8) -> f64; } extern "C" { /// Checks if the motor is drawing over its current limit. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return 1 if the motor's current limit is being exceeded and 0 if the /// current /// limit is not exceeded, or PROS_ERR if the operation failed, setting /// errno. pub fn motor_is_over_current(port: u8) -> i32; } extern "C" { /// Checks if the motor's temperature is above its limit. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return 1 if the temperature limit is exceeded and 0 if the the /// temperature /// is below the limit, or PROS_ERR if the operation failed, setting errno. pub fn motor_is_over_temp(port: u8) -> i32; } extern "C" { /// Gets the absolute position of the motor in its encoder units. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's absolute position in its encoder units or PROS_ERR_F /// if the operation failed, setting errno. pub fn motor_get_position(port: u8) -> f64; } extern "C" { /// Gets the power drawn by the motor in Watts. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's power draw in Watts or PROS_ERR_F if the operation /// failed, setting errno. pub fn motor_get_power(port: u8) -> f64; } extern "C" { /// Gets the temperature of the motor in degrees Celsius. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's temperature in degrees Celsius or PROS_ERR_F if the /// operation failed, setting errno. pub fn motor_get_temperature(port: u8) -> f64; } extern "C" { /// Gets the torque generated by the motor in Newton Meters (Nm). /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's torque in Nm or PROS_ERR_F if the operation failed, /// setting errno. pub fn motor_get_torque(port: u8) -> f64; } extern "C" { /// Gets the voltage delivered to the motor in millivolts. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's voltage in mV or PROS_ERR_F if the operation failed, /// setting errno. pub fn motor_get_voltage(port: u8) -> i32; } pub const motor_brake_mode_e_E_MOTOR_BRAKE_COAST: motor_brake_mode_e = 0; pub const motor_brake_mode_e_E_MOTOR_BRAKE_BRAKE: motor_brake_mode_e = 1; pub const motor_brake_mode_e_E_MOTOR_BRAKE_HOLD: motor_brake_mode_e = 2; pub const motor_brake_mode_e_E_MOTOR_BRAKE_INVALID: motor_brake_mode_e = 2147483647; /// Indicates the current 'brake mode' of a motor. pub type motor_brake_mode_e = u32; /// Indicates the current 'brake mode' of a motor. pub use self::motor_brake_mode_e as motor_brake_mode_e_t; pub const motor_encoder_units_e_E_MOTOR_ENCODER_DEGREES: motor_encoder_units_e = 0; pub const motor_encoder_units_e_E_MOTOR_ENCODER_ROTATIONS: motor_encoder_units_e = 1; pub const motor_encoder_units_e_E_MOTOR_ENCODER_COUNTS: motor_encoder_units_e = 2; pub const motor_encoder_units_e_E_MOTOR_ENCODER_INVALID: motor_encoder_units_e = 2147483647; /// Indicates the units used by the motor encoders. pub type motor_encoder_units_e = u32; /// Indicates the units used by the motor encoders. pub use self::motor_encoder_units_e as motor_encoder_units_e_t; pub const motor_gearset_e_E_MOTOR_GEARSET_36: motor_gearset_e = 0; pub const motor_gearset_e_E_MOTOR_GEARSET_18: motor_gearset_e = 1; pub const motor_gearset_e_E_MOTOR_GEARSET_06: motor_gearset_e = 2; pub const motor_gearset_e_E_MOTOR_GEARSET_INVALID: motor_gearset_e = 2147483647; /// Indicates the current internal gear ratio of a motor. pub type motor_gearset_e = u32; /// Indicates the current internal gear ratio of a motor. pub use self::motor_gearset_e as motor_gearset_e_t; extern "C" { /// Sets the position for the motor in its encoder units. /// /// This will be the future reference point for the motor's "absolute" /// position. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param position /// The new reference position in its encoder units /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_set_zero_position(port: u8, position: f64) -> i32; } extern "C" { /// Sets the "absolute" zero position of the motor to its current position. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_tare_position(port: u8) -> i32; } extern "C" { /// Sets one of motor_brake_mode_e_t to the motor. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param mode /// The motor_brake_mode_e_t to set for the motor /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_set_brake_mode(port: u8, mode: motor_brake_mode_e_t) -> i32; } extern "C" { /// Sets the current limit for the motor in mA. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param limit /// The new current limit in mA /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_set_current_limit(port: u8, limit: i32) -> i32; } extern "C" { /// Sets one of motor_encoder_units_e_t for the motor encoder. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param units /// The new motor encoder units /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_set_encoder_units(port: u8, units: motor_encoder_units_e_t) -> i32; } extern "C" { /// Sets one of motor_gearset_e_t for the motor. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param gearset /// The new motor gearset /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_set_gearing(port: u8, gearset: motor_gearset_e_t) -> i32; } extern "C" { /// Sets the reverse flag for the motor. /// /// This will invert its movements and the values returned for its position. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param reverse /// True reverses the motor, false is default /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_set_reversed(port: u8, reverse: bool) -> i32; } extern "C" { /// Sets the voltage limit for the motor in Volts. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// \param limit /// The new voltage limit in Volts /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn motor_set_voltage_limit(port: u8, limit: i32) -> i32; } extern "C" { /// Gets the brake mode that was set for the motor. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return One of motor_brake_mode_e_t, according to what was set for the /// motor, /// or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. pub fn motor_get_brake_mode(port: u8) -> motor_brake_mode_e_t; } extern "C" { /// Gets the current limit for the motor in mA. /// /// The default value is 2500 mA. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's current limit in mA or PROS_ERR if the operation /// failed, /// setting errno. pub fn motor_get_current_limit(port: u8) -> i32; } extern "C" { /// Gets the encoder units that were set for the motor. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return One of motor_encoder_units_e_t according to what is set for the /// motor /// or E_MOTOR_ENCODER_INVALID if the operation failed. pub fn motor_get_encoder_units(port: u8) -> motor_encoder_units_e_t; } extern "C" { /// Gets the gearset that was set for the motor. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return One of motor_gearset_e_t according to what is set for the motor, /// or E_GEARSET_INVALID if the operation failed. pub fn motor_get_gearing(port: u8) -> motor_gearset_e_t; } extern "C" { /// Gets the operation direction of the motor as set by the user. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return 1 if the motor has been reversed and 0 if the motor was not /// reversed, /// or PROS_ERR if the operation failed, setting errno. pub fn motor_is_reversed(port: u8) -> i32; } extern "C" { /// Gets the voltage limit set by the user. /// /// Default value is 0V, which means that there is no software limitation /// imposed /// on the voltage. /// /// This function uses the following values of errno when an error state is /// reached: /// ENXIO - The given value is not within the range of V5 ports (1-21). /// ENODEV - The port cannot be configured as a motor /// /// \param port /// The V5 port number from 1-21 /// /// \return The motor's voltage limit in V or PROS_ERR if the operation /// failed, /// setting errno. pub fn motor_get_voltage_limit(port: u8) -> i32; } pub type task_t = *mut libc::c_void; pub type task_fn_t = ::core::option::Option<unsafe extern "C" fn(arg1: *mut libc::c_void)>; pub const task_state_e_t_E_TASK_STATE_RUNNING: task_state_e_t = 0; pub const task_state_e_t_E_TASK_STATE_READY: task_state_e_t = 1; pub const task_state_e_t_E_TASK_STATE_BLOCKED: task_state_e_t = 2; pub const task_state_e_t_E_TASK_STATE_SUSPENDED: task_state_e_t = 3; pub const task_state_e_t_E_TASK_STATE_DELETED: task_state_e_t = 4; pub const task_state_e_t_E_TASK_STATE_INVALID: task_state_e_t = 5; pub type task_state_e_t = u32; pub type mutex_t = *mut libc::c_void; extern "C" { /// Gets the number of milliseconds since PROS initialized. /// /// \return The number of milliseconds since PROS initialized pub fn millis() -> u32; } extern "C" { /// Creates a new task and add it to the list of tasks that are ready to /// run. /// /// This function uses the following values of errno when an error state is /// reached: /// ENOMEM - The stack cannot be used as the TCB was not created. /// /// \param function /// Pointer to the task entry function /// \param parameters /// Pointer to memory that will be used as a parameter for the task /// being /// created. This memory should not typically come from stack, but /// rather /// from dynamically (i.e., malloc'd) or statically allocated memory. /// \param prio /// The priority at which the task should run. /// TASK_PRIO_DEFAULT plus/minus 1 or 2 is typically used. /// \param stack_depth /// The number of words (i.e. 4 * stack_depth) available on the /// task's /// stack. TASK_STACK_DEPTH_DEFAULT is typically sufficienct. /// \param name /// A descriptive name for the task. This is mainly used to /// facilitate /// debugging. The name may be up to 32 characters long. /// /// \return A handle by which the newly created task can be referenced. If /// an /// error occurred, NULL will be returned and errno can be checked for hints /// as /// to why task_create failed. pub fn task_create( function: task_fn_t, parameters: *mut libc::c_void, prio: u32, stack_depth: u16, name: *const libc::c_char, ) -> task_t; } extern "C" { /// Removes a task from the RTOS real time kernel's management. The task /// being /// deleted will be removed from all ready, blocked, suspended and event /// lists. /// /// Memory dynamically allocated by the task is not automatically freed, and /// should be freed before the task is deleted. /// /// \param task /// The handle of the task to be deleted. Passing NULL will cause /// the /// calling task to be deleted. pub fn task_delete(task: task_t); } extern "C" { /// Delays a task for a given number of milliseconds. /// /// This is not the best method to have a task execute code at predefined /// intervals, as the delay time is measured from when the delay is /// requested. /// To delay cyclically, use task_delay_until(). /// /// \param milliseconds /// The number of milliseconds to wait (1000 milliseconds per second) pub fn task_delay(milliseconds: u32); } extern "C" { /// Delays a task until a specified time. This function can be used by /// periodic /// tasks to ensure a constant execution frequency. /// /// The task will be woken up at the time *prev_time + delta, and *prev_time /// will /// be updated to reflect the time at which the task will unblock. /// /// \param prev_time /// A pointer to the location storing the setpoint time. This should /// typically be initialized to the return value of millis(). /// \param delta /// The number of milliseconds to wait (1000 milliseconds per second) pub fn task_delay_until(prev_time: *mut u32, delta: u32); } extern "C" { /// Gets the priority of the specified task. /// /// \param task /// The task to check /// /// \return The priority of the task pub fn task_get_priority(task: task_t) -> u32; } extern "C" { /// Gets the state of the specified task. /// /// \param task /// The task to check /// /// \return The state of the task pub fn task_get_state(task: task_t) -> task_state_e_t; } extern "C" { /// Gets the name of the specified task. /// /// \param task /// The task to check /// /// \return A pointer to the name of the task pub fn task_get_name(task: task_t) -> *mut libc::c_char; } extern "C" { /// Gets a task handle from the specified name /// /// The operation takes a relatively long time and should be used sparingly. /// /// \param name /// The name to query /// /// \return A task handle with a matching name, or NULL if none were found. pub fn task_get_by_name(name: *const libc::c_char) -> task_t; } extern "C" { /// Get the currently running task handle. This could be useful if a task /// wants to tell another task about itself. /// /// \return The currently running task handle. pub fn task_get_current() -> task_t; } extern "C" { /// Sends a simple notification to task and increments the notification /// counter. /// /// See https://pros.cs.purdue.edu/v5/tutorials/topical/notifications.html for /// details. /// /// \param task /// The task to notify /// /// \return Always returns true. pub fn task_notify(task: task_t) -> u32; } extern "C" { /// Waits for a notification to be nonzero. /// /// See https://pros.cs.purdue.edu/v5/tutorials/topical/notifications.html for /// details. /// /// \param clear_on_exit /// If true (1), then the notification value is cleared. /// If false (0), then the notification value is decremented. /// \param timeout /// Specifies the amount of time to be spent waiting for a /// notification /// to occur. /// /// \return The value of the task's notification value before it is /// decremented /// or cleared pub fn task_notify_take(clear_on_exit: bool, timeout: u32) -> u32; } extern "C" { /// Deletes a mutex /// /// \param mutex /// Mutex to unlock. pub fn mutex_delete(mutex: mutex_t); } extern "C" { /// Enables generic serial on the given port. /// /// \note This function must be called before any of the generic serial /// functions will work. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn serial_enable(port: u8) -> i32; } extern "C" { /// Sets the baudrate for the serial port to operate at. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// \param baudrate /// The baudrate to operate at /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn serial_set_baudrate(port: u8, baudrate: i32) -> i32; } extern "C" { /// Clears the internal input and output FIFO buffers. /// /// This can be useful to reset state and remove old, potentially unneeded /// data /// from the input FIFO buffer or to cancel sending any data in the output /// FIFO /// buffer. /// /// \note This function does not cause the data in the output buffer to be /// written, it simply clears the internal buffers. Unlike stdout, generic /// serial does not use buffered IO (the FIFO buffers are written as soon /// as possible). /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// /// \return 1 if the operation was successful or PROS_ERR if the operation /// failed, setting errno. pub fn serial_flush(port: u8) -> i32; } extern "C" { /// Returns the number of bytes available to be read in the the port's FIFO /// input buffer. /// /// \note This function does not actually read any bytes, is simply returns /// the /// number of bytes available to be read. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// /// \return The number of bytes avaliable to be read or PROS_ERR if the /// operation /// failed, setting errno. pub fn serial_get_read_avail(port: u8) -> i32; } extern "C" { /// Returns the number of bytes free in the port's FIFO output buffer. /// /// \note This function does not actually write any bytes, is simply returns /// the /// number of bytes free in the port's buffer. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// /// \return The number of bytes free or PROS_ERR if the operation failed, /// setting errno. pub fn serial_get_write_free(port: u8) -> i32; } extern "C" { /// Reads the next byte avaliable in the port's input buffer without /// removing it. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// /// \return The next byte avaliable to be read, -1 if none are available, or /// PROS_ERR if the operation failed, setting errno. pub fn serial_peek_byte(port: u8) -> i32; } extern "C" { /// Reads the next byte avaliable in the port's input buffer. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// /// \return The next byte avaliable to be read, -1 if none are available, or /// PROS_ERR if the operation failed, setting errno. pub fn serial_read_byte(port: u8) -> i32; } extern "C" { /// Reads up to the next length bytes from the port's input buffer and /// places /// them in the user supplied buffer. /// /// \note This function will only return bytes that are currently avaliable /// to be /// read and will not block waiting for any to arrive. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// /// \param port /// The V5 port number from 1-21 /// \param buffer /// The location to place the data read /// \param length /// The maximum number of bytes to read /// /// \return The number of bytes read or PROS_ERR if the operation failed, /// setting /// errno. pub fn serial_read(port: u8, buffer: *mut u8, length: i32) -> i32; } extern "C" { /// Write the given byte to the port's output buffer. /// /// \note Data in the port's output buffer is written to the serial port as /// soon /// as possible on a FIFO basis and can not be done manually by the user. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// EIO - Serious internal write error. /// /// \param port /// The V5 port number from 1-21 /// \param buffer /// The byte to write /// /// \return The number of bytes written or PROS_ERR if the operation failed, /// setting errno. pub fn serial_write_byte(port: u8, buffer: u8) -> i32; } extern "C" { /// Writes up to length bytes from the user supplied buffer to the port's /// output /// buffer. /// /// \note Data in the port's output buffer is written to the serial port as /// soon /// as possible on a FIFO basis and can not be done manually by the user. /// /// This function uses the following values of errno when an error state is /// reached: /// EINVAL - The given value is not within the range of V5 ports (1-21). /// EACCES - Another resource is currently trying to access the port. /// EIO - Serious internal write error. /// /// \param port /// The V5 port number from 1-21 /// \param buffer /// The data to write /// \param length /// The maximum number of bytes to write /// /// \return The number of bytes written or PROS_ERR if the operation failed, /// setting errno. pub fn serial_write(port: u8, buffer: *mut u8, length: i32) -> i32; } pub type sem_t = *mut libc::c_void; extern "C" { /// Creates a recursive mutex which can be locked recursively by the owner. /// /// See /// https://pros.cs.purdue.edu/v5/extended/multitasking.html#recursive_mutexes /// for details. /// /// \return A newly created recursive mutex. pub fn mutex_recursive_create() -> mutex_t; } extern "C" { /// Takes a recursive mutex. /// /// See /// https://pros.cs.purdue.edu/v5/extended/multitasking.html#recursive_mutexes /// for details. /// /// \param mutex /// A mutex handle created by mutex_recursive_create /// \param wait_time /// Amount of time to wait before timing out /// /// \return 1 if the mutex was obtained, 0 otherwise pub fn mutex_recursive_take(mutex: mutex_t, timeout: u32) -> bool; } extern "C" { /// Gives a recursive mutex. /// /// See /// https://pros.cs.purdue.edu/v5/extended/multitasking.html#recursive_mutexes /// for details. /// /// \param mutex /// A mutex handle created by mutex_recursive_create /// /// \return 1 if the mutex was obtained, 0 otherwise pub fn mutex_recursive_give(mutex: mutex_t) -> bool; } extern "C" { /// Creates a counting sempahore. /// /// See https://pros.cs.purdue.edu/v5/tutorials/multitasking.html#semaphores for ///details. /// /// \param max_count /// The maximum count value that can be reached. /// \param init_count /// The initial count value assigned to the new semaphore. /// /// \return A newly created semaphore. If an error occurred, NULL will be /// returned and errno can be checked for hints as to why sem_create failed. pub fn sem_create(max_count: u32, init_count: u32) -> sem_t; } extern "C" { /// Deletes a semaphore (or binary semaphore) /// /// See https://pros.cs.purdue.edu/v5/extended/multitasking.html#semaphores for /// details. /// /// \param sem /// Semaphore to delete pub fn sem_delete(sem: sem_t); } extern "C" { /// Waits for the semaphore's value to be greater than 0. If the value is /// already /// greater than 0, this function immediately returns. /// /// See https://pros.cs.purdue.edu/v5/tutorials/multitasking.html#semaphores for /// details. /// /// \param sem /// Semaphore to wait on /// \param timeout /// Time to wait before the semaphore's becomes available. A timeout /// of 0 /// can be used to poll the sempahore. TIMEOUT_MAX can be used to /// block /// indefinitely. /// /// \return True if the semaphore was successfully take, false otherwise. If /// false is returned, then errno is set with a hint about why the sempahore /// couldn't be taken. pub fn sem_wait(sem: sem_t, timeout: u32) -> bool; } extern "C" { /// Increments a semaphore's value. /// /// See https://pros.cs.purdue.edu/v5/tutorials/multitasking.html#semaphores for /// details. /// /// \param sem /// Semaphore to post /// /// \return True if the value was incremented, false otherwise. If false is /// returned, then errno is set with a hint about why the semaphore couldn't /// be /// taken. pub fn sem_post(sem: sem_t) -> bool; } extern "C" { /// Returns the current value of the semaphore. /// /// See https://pros.cs.purdue.edu/v5/extended/multitasking.html#extra for /// details. /// /// \param sem /// A semaphore handle /// /// \return The current value of the semaphore (e.g. the number of resources /// available) pub fn sem_get_count(sem: sem_t) -> u32; } pub const PROS_ERR_: i32 = 2147483647; pub const PROS_ERR_F_: f64 = ::core::f64::INFINITY;