pavel-kirienko/uavcan — pull request #5 by gtoonstra (2014-11-02 01:28:43+00:00)
Title: Exploration C generation

Pavel,

This is some very preliminary code that demonstrates some results of generating C code. Most of it is copied straight from the existing compiler. At the moment it only outputs the structures based on the dsdl. The marshalling code still needs to be generated. Probably I need to change the extension to H and do the implementation for message handling in the header file.

What's missing is a very thin protocol layer implementation that indicates which message has been received, so the user can call the marshalling code functions and of course the utility functions that the message marshalling functions can call. The reason to do it that way is to prevent the codebase pulling in the entire implementation, so there's a decoupling between the protocol layer and the individual message implementations.

As you can see in the compiler run script, I just added another invocation to a different directory, where all the code is being generated, so you should be able to evaluate the pull request, compile the whole lot and inspect those C files.

Compound types are not supported yet and changes are needed on the structure naming convention.

Some example output of the ESC messages:
-----------
typedef struct uavcan_equipment_esc_RawCommand_cmd_t {
signed int cmd:14;
};

typedef struct UAVCAN_EXPORT uavcan_equipment_esc_RawCommand_t
{
struct uavcan_equipment_esc_RawCommand_cmd_t cmd[20];
};

void unmarshall_uavcan_equipment_esc_RawCommand( void )
{

}

void marshall_uavcan_equipment_esc_RawCommand( void )
{

}

-----
enum uavcan_equipment_power_CircuitStatus_Constants_t
{
ERROR_MASK_OVERVOLTAGE = 1U,
ERROR_MASK_UNDERVOLTAGE = 2U,
ERROR_MASK_OVERCURRENT = 4U,
ERROR_MASK_UNDERCURRENT = 8U
};

typedef struct UAVCAN_EXPORT uavcan_equipment_power_CircuitStatus_t
{
unsigned int circuit_id: 8;
unsigned int error_mask: 8;
float voltage;
float current;
};

void unmarshall_uavcan_equipment_power_CircuitStatus( void )
{

}

void marshall_uavcan_equipment_power_CircuitStatus( void )
{

}