### Install XILab Packages on RedHat/OpenSUSE (Text Installer) Source: https://en.xisupport.com/projects/enxisupport/wiki/Installation_on_Linux Use 'zypper' to install XILab and its dependencies from .rpm packages. Replace placeholders with actual file paths, versions, and architecture. ```bash zypper install "/libximc6--1..rpm" zypper install "/xilab--1..rpm" ``` ```bash zypper install "/home/user/Downloads/libximc6-2.0.2-1.x86_64.rpm" zypper install "/home/user/Downloads/xilab-1.8.12-1.x86_64.rpm" ``` -------------------------------- ### Install XILab Packages on Debian/Ubuntu (Text Installer) Source: https://en.xisupport.com/projects/enxisupport/wiki/Installation_on_Linux Use 'gdebi' to install XILab and its dependencies from .deb packages. Replace placeholders with actual file paths, versions, and architecture. ```bash gdebi "/libximc6_-1_.deb" gdebi "/xilab--1_.deb" ``` ```bash gdebi "/home/user/Downloads/libximc6-2.0.2-1_amd64.deb" gdebi "/home/user/Downloads/xilab-1.8.12-1_amd64.deb" ``` -------------------------------- ### Application Example: usmcdll_libximc_test.zip Source: https://en.xisupport.com/projects/enxisupport/wiki/8SMC1-USBhF_software_compatibility This zip file contains an application example demonstrating the use of usmcdll and libximc. ```zip usmcdll_libximc_test.zip ``` -------------------------------- ### GET GGRI (Get Gear Information) Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads gear information from EEPROM. ```APIDOC ## GET GGRI ### Description Read gear information from EEPROM. ### Response - **Manufacturer** (CHAR[16]) - Manufacturer name - **PartNumber** (CHAR[24]) - Series and PartNumber - **Reserved** (INT8U[24]) - Reserved bytes - **CRC** (INT16U) - Checksum ``` -------------------------------- ### Get Accessories Settings Command Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Retrieves accessory configuration data from EEPROM. ```c result_t get_accessories_settings (device_t id, accessories_settings_t* accessories_settings) ``` -------------------------------- ### GET GGRS (Get Gear Settings) Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads gear settings from EEPROM. ```APIDOC ## GET GGRS ### Description Read gear settings from EEPROM. ### Response - **ReductionIn** (FLT32) - Input reduction coefficient - **ReductionOut** (FLT32) - Output reduction coefficient - **RatedInputTorque** (FLT32) - Max continuous torque (N m) - **RatedInputSpeed** (FLT32) - Max speed on the input shaft (rpm) - **MaxOutputBacklash** (FLT32) - Output backlash of the reduction gear (degree) - **InputInertia** (FLT32) - Equivalent input gear inertia (g cm2) - **Efficiency** (FLT32) - Reduction gear efficiency (%) - **Reserved** (INT8U[24]) - Reserved bytes - **CRC** (INT16U) - Checksum ``` -------------------------------- ### Command GENI (Get Encoder Information) Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads encoder information from EEPROM. ```APIDOC ## GET GENI ### Description Read encoder information from EEPROM. ### Request - **CMD** (INT32U) - Command code: 0x696E6567 ### Response - **Manufacturer** (CHAR[16]) - Manufacturer name - **PartNumber** (CHAR[24]) - Series and PartNumber - **CRC** (INT16U) - Checksum ``` -------------------------------- ### Command GSTS (Get Stage Settings) Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads stage settings from EEPROM. ```APIDOC ## GSTS (Get Stage Settings) ### Description Read stage settings from EEPROM. ### Request Body - **CMD** (INT32U) - Command code (0x73747367) ### Response #### Success Response (70 bytes) - **CMD** (INT32U) - Command answer - **LeadScrewPitch** (FLT32) - Lead screw pitch (mm) - **Units** (CHAR[8]) - Units - **MaxSpeed** (FLT32) - Max speed - **TravelRange** (FLT32) - Travel range - **SupplyVoltageMin** (FLT32) - Min supply voltage - **SupplyVoltageMax** (FLT32) - Max supply voltage - **MaxCurrentConsumption** (FLT32) - Max current consumption - **HorizontalLoadCapacity** (FLT32) - Horizontal load capacity - **VerticalLoadCapacity** (FLT32) - Vertical load capacity - **Reserved** (INT8U[24]) - Reserved bytes - **CRC** (INT16U) - Checksum ``` -------------------------------- ### Get Globally Unique Identifier (GUID) Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Retrieves a unique device identifier from the controller. This ID is unique to each die and can be used as a serial number or for secure boot processes. ```APIDOC ## Get Globally Unique Identifier (GUID) ### Description This value is unique to each individual die but is not a random value. This unique device identifier can be used to initiate secure boot processes or as a serial number for USB or other end applications. ### Method POST ### Endpoint /command ### Parameters #### Request Body - **CMD** (INT32U) - Required - Command code for get_globally_unique_identifier (0x64697567 or "guid") ### Request Example ```json { "CMD": "guid" } ``` ### Response #### Success Response (200) - **CMD** (INT32U) - Command code for the answer (0x64697567 or "guid") - **UniqueID0** (INT32U) - Unique ID 0 - **UniqueID1** (INT32U) - Unique ID 1 - **UniqueID2** (INT32U) - Unique ID 2 - **UniqueID3** (INT32U) - Unique ID 3 - **Reserved** (INT8U[18]) - Reserved (18 bytes) - **CRC** (INT16U) - Checksum #### Response Example ```json { "CMD": "guid", "UniqueID0": 1234567890, "UniqueID1": 9876543210, "UniqueID2": 1122334455, "UniqueID3": 6677889900, "Reserved": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "CRC": 98765 } ``` ``` -------------------------------- ### Create and Write to File Objects Source: https://en.xisupport.com/projects/enxisupport/wiki/XILab_scripts Demonstrates initializing a file object with a path and performing basic read/write operations with error handling. ```javascript var winf = new_file("C:/file.txt"); // An example of file name and path on Windows var linf = new_file("/home/user/Desktop/file.txt"); // An example of file name and path on Linux var macf = new_file("/Users/macuser/file.txt"); // An example of file name and path on Mac var f = winf; // Pick a file name if (f.open()) { // Try to open the file f.write( "some text" ); // If successful, then write desired data to the file f.close(); // Close the file } else { // If file open failed for some reason log( "Failed opening file" ); // Log an error } ``` -------------------------------- ### POST /seio Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Sets the external I/O configuration settings in the controller's memory. ```APIDOC ## POST /seio ### Description Writes a structure with a set of EXTIO settings to the controller's memory. ### Method POST ### Endpoint /seio ### Request Body - **CMD** (INT32U) - Required - Command code 0x6F696573 - **EXTIOSetupFlags** (INT8U) - Required - Configuration flags (0x01: Output, 0x02: Invert) - **EXTIOModeFlags** (INT8U) - Required - Mode settings for input/output behavior - **Reserved** (INT8U[10]) - Required - Reserved bytes - **CRC** (INT16U) - Required - Checksum ### Response #### Success Response (200) - **CMD** (INT32U) - Command answer ``` -------------------------------- ### GET GHSS (Get Hall Sensor Settings) Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads hall sensor settings from the device EEPROM. ```APIDOC ## GET GHSS ### Description Read hall sensor settings from EEPROM. ### Request - **CMD** (INT32U) - Command code: 0x73736867 ### Response - **MaxOperatingFrequency** (FLT32) - Max operation frequency (kHz) - **SupplyVoltageMin** (FLT32) - Minimum supply voltage (V) - **SupplyVoltageMax** (FLT32) - Maximum supply voltage (V) - **MaxCurrentConsumption** (FLT32) - Max current consumption (mA) - **PPR** (INT32U) - The number of counts per revolution - **Reserved** (INT8U[24]) - Reserved bytes - **CRC** (INT16U) - Checksum ``` -------------------------------- ### Flash firmware image on Unix Source: https://en.xisupport.com/projects/enxisupport/wiki/Web_interface Use the dd utility to write the autoinstaller image to the MicroSD card. Ensure the device path is correctly identified to avoid data loss on other drives. ```bash dd if=autoinstall_image_2015-12-17.bin of=/dev/sdX bs=4M; sync ``` -------------------------------- ### GET /gfbs - Get Feedback Settings Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Retrieves the current feedback settings for a specified device. This command returns detailed information about the configured feedback mechanisms. ```APIDOC ## GET /gfbs - Get Feedback Settings ### Description Retrieves the current feedback settings for a specified device. This command returns detailed information about the configured feedback mechanisms. ### Method GET ### Endpoint /gfbs ### Parameters #### Query Parameters - **id** (device_t) - Required - Identifier for the device. ### Response #### Success Response (200) - **CMD** (INT32U) - Command confirmation. - **IPS** (INT16U) - The number of encoder counts per shaft revolution. Range: 1..65535. - **FeedbackType** (INT8U) - Type of feedback. - 0x01 - FEEDBACK_ENCODER - 0x03 - FEEDBACK_ENCODERHALL - 0x04 - FEEDBACK_EMF - 0x05 - FEEDBACK_NONE - **FeedbackFlags** (INT8U) - Flags for feedback configuration. - 0x01 - FEEDBACK_ENC_REVERSE - 0x02 - FEEDBACK_HALL_REVERSE - 0xC0 - FEEDBACK_ENC_TYPE_BITS - 0x00 - FEEDBACK_ENC_TYPE_AUTO - 0x40 - FEEDBACK_ENC_TYPE_SINGLE_ENDED - 0x80 - FEEDBACK_ENC_TYPE_DIFFERENTIAL - **HallSPR** (INT16U) - The number of hall steps per revolution. - **HallShift** (INT8S) - Phase shift between output signal and hall sensor input. - **Reserved** (INT8U[5]) - Reserved (5 bytes). - **CRC** (INT16U) - Checksum. #### Response Example ```json { "CMD": "0x73626667", "IPS": 1024, "FeedbackType": "0x01", "FeedbackFlags": "0x00", "HallSPR": 1024, "HallShift": 0, "Reserved": [0, 0, 0, 0, 0], "CRC": 12345 } ``` ``` -------------------------------- ### Configure Controller Movement and Log Data Source: https://en.xisupport.com/projects/enxisupport/wiki/Csv_file_read_save Sets movement parameters, moves to a start position, and iterates through steps while logging data to a file. ```javascript var start = 0; // Starting coordinate in steps var step = 10; // Shift amount in steps var end = 100; // Ending coordinate in steps var speed = 300; // maximum movement speed in steps / second var accel = 100; // acceleration value in steps / second^2 var decel = 100; // deceleration value in steps / second^2 var delay = 100; var m = get_move_settings(); // read movement settings from the controller m.Speed = speed; // set movement speed m.Accel = accel; // set acceleration m.Decel = decel; // set deceleration set_move_settings(m); // write movement settings into the controller var f = new_file("C:/a.csv"); // Choose a file name and path f.open(); // Open a file f.seek( 0 ); // Seek to the beginning of the file command_move(start); // Move to the starting position command_wait_for_stop(delay); // Wait until controller stops moving while (get_status().CurPosition < end) { f.write( get_status().CurPosition + "," + get_chart_data().Pot + "," + Date.now() + "\n" ); // Get current position, potentiometer value and date and write them to file command_movr(step); // Move to the next position command_wait_for_stop(delay); // Wait until controller stops moving } f.close(); // Close the file ``` -------------------------------- ### GETS Command API Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification This section details the 'gets' command used to retrieve the status of a device. It includes the command format, expected answer structure, and explanations for each status field. ```APIDOC ## GETS Command ### Description Retrieves the current status of a device, including movement state, power state, encoder status, winding status, position, speed, and various system flags. ### Method GET ### Endpoint /websites/en_xisupport ### Parameters #### Path Parameters - **id** (device_t) - Required - Identifier for the target device. #### Query Parameters - **status** (status_t*) - Optional - Pointer to a status structure to store the retrieved status. ### Request Example ```json { "command": "gets", "device_id": "your_device_id" } ``` ### Response #### Success Response (200) - **MoveSts** (INT8U) - Move state flags. - **MvCmdSts** (INT8U) - Move command state flags. - **PWRSts** (INT8U) - Power state of the stepper motor. - **EncSts** (INT8U) - Encoder state. - **WindSts** (INT8U) - Winding state. - **CurPosition** (INT32S) - Current position. - **uCurPosition** (INT16S) - Step motor shaft position in 1/256 microsteps. - **EncPosition** (INT64S) - Current encoder position. - **CurSpeed** (INT32S) - Motor shaft speed. - **uCurSpeed** (INT16S) - Part of motor shaft speed in 1/256 microsteps. - **Ipwr** (INT16S) - Engine current. - **Upwr** (INT16S) - Power supply voltage, tens of mV. - **Iusb** (INT16S) - USB current consumption. - **Uusb** (INT16S) - USB voltage, tens of mV. - **CurT** (INT16S) - Temperature in tenths of degrees C. - **Flags** (INT32U) - Set of flags specifying motor shaft movement algorithm and limitations. #### Response Example ```json { "MoveSts": 1, "MvCmdSts": 1, "PWRSts": 3, "EncSts": 4, "WindSts": 51, "CurPosition": 1000, "uCurPosition": 256, "EncPosition": 2000000, "CurSpeed": 500, "uCurSpeed": 128, "Ipwr": 100, "Upwr": 12000, "Iusb": 500, "Uusb": 5000, "CurT": 450, "Flags": 131072 } ``` ### Status Codes **MoveSts Flags:** - `0x01` - `MOVE_STATE_MOVING`: Controller is trying to move the motor. - `0x02` - `MOVE_STATE_TARGET_SPEED`: Target speed is reached. - `0x04` - `MOVE_STATE_ANTIPLAY`: Motor is playing compensation. **MvCmdSts Flags:** - `0x3F` - `MVCMD_NAME_BITS`: Move command bit mask. - `0x00` - `MVCMD_UKNWN`: Unknown command. - `0x01` - `MVCMD_MOVE`: Command move. - `0x02` - `MVCMD_MOVR`: Command movr. - `0x03` - `MVCMD_LEFT`: Command left. - `0x04` - `MVCMD_RIGHT`: Command rigt. - `0x05` - `MVCMD_STOP`: Command stop. - `0x06` - `MVCMD_HOME`: Command home. - `0x07` - `MVCMD_LOFT`: Command loft. - `0x08` - `MVCMD_SSTP`: Command soft stop. - `0x40` - `MVCMD_ERROR`: Move command finished with an error. - `0x80` - `MVCMD_RUNNING`: Move command is being executed. **PWRSts Flags:** - `0x00` - `PWR_STATE_UNKNOWN`: Unknown state. - `0x01` - `PWR_STATE_OFF`: Motor windings are disconnected. - `0x03` - `PWR_STATE_NORM`: Motor windings are powered by nominal current. - `0x04` - `PWR_STATE_REDUCT`: Motor windings are powered by reduced current. - `0x05` - `PWR_STATE_MAX`: Motor windings are powered by maximum current. **EncSts Flags:** - `0x00` - `ENC_STATE_ABSENT`: Encoder is absent. - `0x01` - `ENC_STATE_UNKNOWN`: Encoder state is unknown. - `0x02` - `ENC_STATE_MALFUNC`: Encoder is malfunctioning. - `0x03` - `ENC_STATE_REVERS`: Encoder counts in the other direction. - `0x04` - `ENC_STATE_OK`: Encoder is connected and working properly. **WindSts Flags:** - `0x00` - `WIND_A_STATE_ABSENT`: Winding A is disconnected. - `0x01` - `WIND_A_STATE_UNKNOWN`: Winding A state is unknown. - `0x02` - `WIND_A_STATE_MALFUNC`: Winding A is short-circuited. - `0x03` - `WIND_A_STATE_OK`: Winding A is connected and working properly. - `0x00` - `WIND_B_STATE_ABSENT`: Winding B is disconnected. - `0x10` - `WIND_B_STATE_UNKNOWN`: Winding B state is unknown. - `0x20` - `WIND_B_STATE_MALFUNC`: Winding B is short-circuited. - `0x30` - `WIND_B_STATE_OK`: Winding B is connected and working properly. **Flags Field Bitmasks:** - `0x00003F` - `STATE_CONTR`: Controller states. - `0x000001` - `STATE_ERRC`: Command error encountered. - `0x000002` - `STATE_ERRD`: Data integrity error encountered. - `0x000004` - `STATE_ERRV`: Value error encountered. - `0x000010` - `STATE_EEPROM_CONNECTED`: EEPROM with settings is connected. - `0x000020` - `STATE_IS_HOMED`: Calibration performed. - `0x73FFC0` - `STATE_SECUR`: Security flags. - `0x000040` - `STATE_ALARM`: Controller is in alarm state. - `0x000080` - `STATE_CTP_ERROR`: Control position error. - `0x000100` - `STATE_POWER_OVERHEAT`: Power driver overheat. - `0x000200` - `STATE_CONTROLLER_OVERHEAT`: Controller overheat. - `0x000400` - `STATE_OVERLOAD_POWER_VOLTAGE`: Power voltage exceeds safe limit. - `0x000800` - `STATE_OVERLOAD_POWER_CURRENT`: Power current exceeds safe limit. - `0x001000` - `STATE_OVERLOAD_USB_VOLTAGE`: USB voltage exceeds safe limit. - `0x002000` - `STATE_LOW_USB_VOLTAGE`: USB voltage is insufficient. - `0x004000` - `STATE_OVERLOAD_USB_CURRENT`: USB current exceeds safe limit. - `0x008000` - `STATE_BORDERS_SWAP_MISSET`: Engine stuck at the wrong edge. - `0x010000` - `STATE_LOW_POWER_VOLTAGE`: Power voltage is lower than Low Voltage Protection limit. ``` -------------------------------- ### Create Calibration Structures Source: https://en.xisupport.com/projects/enxisupport/wiki/XILab_scripts Shows two equivalent methods for defining calibration parameters for motor steps and microstep modes. ```javascript // create calibration: type 1 var calb = new_calibration(c1, c2); ``` ```javascript // create calibration: type 2 var calb = new Object(); calb.A = c1; calb.MicrostepMode = c2; ``` -------------------------------- ### GET /api/firmware/version Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Retrieves the firmware version of the controller. ```APIDOC ## GET /api/firmware/version ### Description Read controller's firmware version. ### Method GET ### Endpoint /api/firmware/version ### Parameters #### Query Parameters - **id** (device_t) - Required - Identifier for the device. ### Response #### Success Response (200) - **Major** (INT8U) - Firmware major version number. - **Minor** (INT8U) - Firmware minor version number. - **Release** (INT16U) - Firmware release version number. - **CRC** (INT16U) - Checksum. #### Response Example ```json { "Major": 2, "Minor": 1, "Release": 10, "CRC": 98765 } ``` ``` -------------------------------- ### POST /shom Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Sets the home calibration settings by sending a structure to the controller's memory. ```APIDOC ## POST /shom ### Description Set home settings. This function sends a structure with calibrating position settings to the controller's memory. ### Method POST ### Endpoint /shom ### Request Body - **CMD** (INT32U) - Command code (0x6D6F6873) - **FastHome** (INT32U) - Speed used for first motion. Range: 0..100000. - **uFastHome** (INT8U) - Part of the speed for first motion, microsteps. - **SlowHome** (INT32U) - Speed used for second motion. Range: 0..100000. - **uSlowHome** (INT8U) - Part of the speed for second motion, microsteps. - **HomeDelta** (INT32S) - Distance from break point. - **uHomeDelta** (INT16S) - Part of the delta distance, microsteps. Range: -255..255. - **HomeFlags** (INT16U) - Set of flags specifying direction and stopping conditions. - **Reserved** (INT8U[9]) - Reserved bytes. - **CRC** (INT16U) - Checksum. ### Response #### Success Response (200) - **CMD** (INT32U) - Command (answer) ``` -------------------------------- ### GET /gcal Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads the calibration settings from the device. ```APIDOC ## GET gcal ### Description Read calibration settings from the device and fill the calibration structure. ### Method GET ### Endpoint gcal ### Response #### Success Response (200) - **CSS1_A** (FLT32) - Scaling factor for the analogue measurements of the winding A current. - **CSS1_B** (FLT32) - Shift factor for the analogue measurements of the winding A current. - **CSS2_A** (FLT32) - Scaling factor for the analogue measurements of the winding B current. - **CSS2_B** (FLT32) - Shift factor for the analogue measurements of the winding B current. - **FullCurrent_A** (FLT32) - Scaling factor for the analogue measurements of the full current. - **FullCurrent_B** (FLT32) - Scaling factor for the analogue measurements of the full current. - **CRC** (INT16U) - Checksum ``` -------------------------------- ### Set Controller Settings via Object Initialization Source: https://en.xisupport.com/projects/enxisupport/wiki/Xilab_scripts Creates a new object and sets all required properties manually. Missing properties are initialized to zero. ```javascript // set settings: type 2 var m = new Object; m.Speed = 100; m.uSpeed = 0; m.Accel = 300; m.Decel = 500; m.AntiplaySpeed = 10; m.uAntiplaySpeed = 0; set_move_settings(m); ``` -------------------------------- ### GET /gacc Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads additional accessories information from EEPROM. ```APIDOC ## GET /gacc ### Description Read additional accessories information from EEPROM. ### Method GET ### Endpoint /gacc ### Response #### Success Response (200) - **MagneticBrakeInfo** (CHAR[24]) - Manufacturer and part number of magnetic brake - **MBRatedVoltage** (FLT32) - Rated voltage for magnetic brake (V) - **MBRatedCurrent** (FLT32) - Rated current for magnetic brake (A) - **MBTorque** (FLT32) - Retention moment (mN m) - **MBSettings** (INT32U) - Flags for magnetic brake settings - **TemperatureSensorInfo** (CHAR[24]) - Manufacturer and part number of temperature sensor - **TSMin** (FLT32) - Minimum measured temperature (Celsius) - **TSMax** (FLT32) - Maximum measured temperature (Celsius) - **TSGrad** (FLT32) - Temperature gradient (V/Celsius) - **TSSettings** (INT32U) - Flags for temperature sensor settings - **LimitSwitchesSettings** (INT32U) - Flags for limit switches settings - **Reserved** (INT8U[24]) - Reserved bytes - **CRC** (INT16U) - Checksum ``` -------------------------------- ### Read Settings Command Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Loads all settings from flash memory into RAM, overwriting current RAM data. ```c result_t command_read_settings (device_t id) ``` -------------------------------- ### GET /api/device/serial-number Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads the device's serial number. ```APIDOC ## GET /api/device/serial-number ### Description Read device serial number. ### Method GET ### Endpoint /api/device/serial-number ### Parameters #### Query Parameters - **id** (device_t) - Required - Identifier for the device. ### Response #### Success Response (200) - **SerialNumber** (INT32U) - Board serial number. - **CRC** (INT16U) - Checksum. #### Response Example ```json { "SerialNumber": 1234567890, "CRC": 54321 } ``` ``` -------------------------------- ### Bitmask Example for Limit Switch Status Source: https://en.xisupport.com/projects/enxisupport/wiki/XILab_scripts This script demonstrates how to use bitmasks to check the status of limit switches using GPIO flags. It defines helper functions for binary conversion and string repetition. Ensure the axis object and constants like STATE_LEFT_EDGE and STATE_RIGHT_EDGE are available. ```javascript /* Bitmask example script */ var a = new_axis(get_next_serial(0)); // take first found axis var gets = a.get_status(); // read status once and reuse it var gpio = gets.GPIOFlags; var left = STATE_LEFT_EDGE; var right = STATE_RIGHT_EDGE; var mask = left | right; var result = gpio & mask; log( to_binary(left) + " = left limit switch flag" ); log( to_binary(right) + " = right limit switch flag" ); log( to_binary(mask) + " = OR operation on flags gives the mask" ); log( to_binary(gpio) + " = gpio state" ); log( to_binary(result) + " = AND operation on state and mask gives result" ); if ( result ) { log("At least one limit switch is on"); } else { log("Both limit switches are off"); } // Binary representation function function to_binary(i) { bits = 32; x = i >>> 0; // coerce to unsigned in case we need to print negative ints str = x.toString(2); // the binary representation string return (repeat("0", bits) + str).slice (-bits); // pad with zeroes and return } // String repeat function function repeat(str, times) { var result=""; var pattern=str; while (times > 0) { if (times&1) { result+=pattern; } times>>=1; pattern+=pattern; } return result; } ``` -------------------------------- ### Get Non-Volatile Memory Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads user data from FRAM. ```c result_t get_nonvolatile_memory (device_t id, nonvolatile_memory_t* nonvolatile_memory) ``` -------------------------------- ### Download USMCDLL/libximc Compatibility Library Source: https://en.xisupport.com/projects/enxisupport/wiki/8SMC1-USBhF_software_compatibility Download the USMCDLL/libximc compatibility library to control motor controllers without MicroSMC software. ```text Download USMCDLL/libximc compatibility library here. ``` -------------------------------- ### Get Secure Settings Source: https://en.xisupport.com/projects/enxisupport/wiki/Communication_protocol_specification Reads the protection settings of the device. ```APIDOC ## GET /api/device/secure_settings ### Description Retrieves the current protection settings configured on the device. ### Method GET ### Endpoint /api/device/secure_settings ### Parameters #### Query Parameters - **id** (device_t) - Required - Identifier for the target device. ### Response #### Success Response (200) - **CMD** (INT32U) - Command code indicating success. - **LowUpwrOff** (INT16U) - Lower voltage limit to turn off the motor, in tens of mV. - **CriticalIpwr** (INT16U) - Maximum motor current which triggers ALARM state, in mA. - **CriticalUpwr** (INT16U) - Maximum motor voltage which triggers ALARM state, in tens of mV. - **CriticalT** (INT16U) - Maximum temperature, which triggers ALARM state, in tenths of degrees Celsius. - **CriticalIusb** (INT16U) - Maximum USB current which triggers ALARM state, in mA. - **CriticalUusb** (INT16U) - Maximum USB voltage which triggers ALARM state, in tens of mV. - **MinimumUusb** (INT16U) - Minimum USB voltage which triggers ALARM state, in tens of mV. - **Flags** (INT8U) - Critical parameter flags. See details in the description. - **Reserved** (INT8U[7]) - Reserved bytes. - **CRC** (INT16U) - Checksum of the response. #### Response Example ```json { "CMD": 1667591787, "LowUpwrOff": 100, "CriticalIpwr": 5000, "CriticalUpwr": 1200, "CriticalT": 850, "CriticalIusb": 2000, "CriticalUusb": 500, "MinimumUusb": 400, "Flags": 7, "Reserved": [0, 0, 0, 0, 0, 0, 0], "CRC": 12345 } ``` ```