Skip to content

Commit

Permalink
Merge pull request #129 from RICCIARDI-Adrien/add_posix_examples_ci
Browse files Browse the repository at this point in the history
ci: Added POSIX examples build.
  • Loading branch information
jlbirccyn authored Sep 19, 2023
2 parents 0323041 + 832cb89 commit 5deaff4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,23 @@ jobs:
- name: Build the code
run: ./build.py
working-directory: examples/avr/arduinoMega2560/${{ matrix.example_name }}

posix-examples:
name: Build POSIX examples
runs-on: ubuntu-22.04
needs: goil
strategy:
matrix:
example_name: [can_demo, events, ioc, isr, messages, one_task, periodic, trace_test]
steps:
- name: Retrieve sources and Goil binary
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}
key: ${{ env.CACHE_KEY }}
- name: Generate the code
run: ${{ env.GOIL }} --target=posix/linux --templates=../../../goil/templates/ ${{ matrix.example_name }}.oil
working-directory: examples/posix/${{ matrix.example_name }}
- name: Build the code
run: ./build.py
working-directory: examples/posix/${{ matrix.example_name }}
4 changes: 2 additions & 2 deletions examples/posix/can_demo/can_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ TASK(can_task)

printf("Transmitting a CAN 2.0 frame with standard ID...\r\n");
can_pdu.id = 0x123 | TPL_CAN_ID_TYPE_STANDARD;
strcpy(payload, "Ciao !");
can_pdu.length = strlen(payload);
strcpy((char *) payload, "Ciao !");
can_pdu.length = strlen((char *) payload);
can_pdu.sdu = payload;
pdu_info.SduDataPtr = (uint8 *) &can_pdu;
pdu_info.SduLength = sizeof(can_pdu);
Expand Down
1 change: 1 addition & 0 deletions examples/posix/can_demo/can_demo.oil
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CPU can_task {
LDFLAGS = "-lrt -lpthread";
APP_NAME = "can_demo_exe";
LINKER = "gcc";
CFLAGS = "-W -Wall";
SYSTEM = PYTHON;
LIBRARY = can;
};
Expand Down
12 changes: 9 additions & 3 deletions machines/posix/tpl_can_demo_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ tpl_can_controller_t can_demo_driver_controller_2 =

static int can_demo_driver_init(struct tpl_can_controller_t *ctrl, void *data)
{
(void) data;

printf("[%s:%d] Initialized controller 0x%08X.\r\n", __func__, __LINE__, ctrl->base_address);
return 0;
}
Expand All @@ -81,7 +83,7 @@ static int can_demo_driver_set_baudrate(struct tpl_can_controller_t *ctrl, tpl_c

if (baud_rate >= CAN_BAUD_RATE_COUNT)
{
printf("[%s:%d] Wrong baud rate code %d, aborting.\r\n", baud_rate);
printf("[%s:%d] Wrong baud rate code %d, aborting.\r\n", __func__, __LINE__, baud_rate);
return -1;
}
bits_per_second = baud_rate_lut[baud_rate];
Expand All @@ -105,13 +107,17 @@ static Std_ReturnType can_demo_driver_transmit(struct tpl_can_controller_t *ctrl

static Std_ReturnType can_demo_driver_receive(struct tpl_can_controller_t *ctrl, Can_PduType *pdu_info)
{
(void) ctrl;

pdu_info->id = 0x1ab; // Random value
strcpy(pdu_info->sdu, "Test");
pdu_info->length = strlen(pdu_info->sdu);
strcpy((char *) pdu_info->sdu, "Test");
pdu_info->length = strlen((char *) pdu_info->sdu);
return 0;
}

static int can_demo_driver_is_data_available(struct tpl_can_controller_t *ctrl)
{
(void) ctrl;

return 1;
}

0 comments on commit 5deaff4

Please sign in to comment.