Can VEXIQ communicate with other devices through methods such as UART or IIC?

Can VEXIQ communicate with other devices through methods such as UART or IIC?I hope VEXIQ can read the sensor data I made myself. Is there any way or idea to achieve this operation?

This may be of interest

IQ Generation 2 can also communicate using asynchronous communication on some ports (ie.uart at logic levels)

2 Likes

Thank you very much for your reply, and I am very sorry that I seem to have been a little verbose. I seem to have some new discoveries, and here IIC and UART related code, because it is encapsulated into a library file, through the function return value definition and input parameter definition, I can guess what is probably doing, but I still do not know where to find the details of these functions?


The code comes from:
C:\Users\pc\AppData\Roaming\Code\User\globalStorage\vexrobotics.vexcode\sdk\cpp\IQ2\IQ2_20231003_10_00_00\vexiq2\include\iq2_api.h

Great project, that’s a great start, but I’ve noticed that the project seems to be using ROBOTC as a programming tool, which doesn’t seem to be officially supported anymore, and the prevailing approach now is: VSCODE or VEXcode IQ, but I did not find the IIC-related API code in the C++ support page [Comprehensive Guide to C++ on VEX IQ (2nd Generation) — VEXcode Documentation](https://VEX IQ (2nd gen) C++) , and VSCODE seems to be unable to directly fail to? Did I miss anything?

Sure, it’s 11 years old, but concepts are the same.

Yea, you shouldn’t use those. There is a C++ class for i2c, uart would just use stdio. Not near a computer for a few days so cont help much more right now.

I successfully read some data, very simple, much simpler than I thought, even do not need to simulate a VEXIQ sensor, only need to directly read the IIC bus.
Use any controller as long as it can be used as an iic_slave.
I will continue to share with you if there are other developments.
Thank you. I wish you a happy day.


you can use the vex::generic class and avoid the low level C calls if you want. For raw IO use.

        /*--------------------------------------------------------------------*/
        //
        // The following methods are for communication with generic devices
        // that do not conform to the IQ sensor reference spec and have an I2C
        // address that does not conflict with other sensors on the same bus.
        // raw sensors should not use I2C addresses that may be assigned to IQ
        // devices if sharing the bus with them.
        // (8 bit addresses)
        // 0x60
        // 0x20, 0x22, 0x24
        /*--------------------------------------------------------------------*/
        
        /**
         * @brief  Read bytes from the device.
         * @param  addr the 7 bit i2C address of the device
         * @param  pBytes pointer to buffer to read into 
         * @param  nLength number of bytes to read
         * @return number of bytes read, < 0 if error
         */
        int32_t readRaw( uint8_t addr, uint8_t *pBytes, uint8_t nLength );
        /**
         * @brief  Write bytes to the device.
         * @param  addr the 7 bit i2C address of the device
         * @param  pBytes pointer to buffer with data
         * @param  nLength number of bytes to write
         * @return number of bytes written, < 0 if error
         */
        int32_t writeRaw( uint8_t addr, uint8_t *pBytes, uint8_t nLength );
        /**
         * @brief  Write bytes to the device.
         * @param  addr the 7 bit i2C address of the device
         * @param  pBytes pointer to buffer with tx data
         * @param  nLength number of bytes to write
         * @param  pRxBytes pointer to buffer with rx data 
         * @param  nRxLength number of bytes to read
         * @return number of bytes read, < 0 if error
         */
        int32_t writeReadRaw( uint8_t addr, uint8_t *pBytes, uint8_t nLength, uint8_t *pRxBytes, uint8_t nRxLength );