Skip to content

Commit eb15e42

Browse files
authored
Merge pull request #430 from tropicsquare/ETR01SDK-529-Fix-buffering-of-examples
ETR01SDK-529: Fix buffering of examples
2 parents 166e044 + ae886f8 commit eb15e42

File tree

10 files changed

+50
-0
lines changed

10 files changed

+50
-0
lines changed

examples/linux/spi_devkit/fw_update/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ lt_ret_t get_fw_versions(lt_handle_t *lt_handle)
4545

4646
int main(void)
4747
{
48+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
49+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
50+
setvbuf(stdout, NULL, _IONBF, 0);
51+
setvbuf(stderr, NULL, _IONBF, 0);
52+
4853
printf("==========================================\n");
4954
printf("==== TROPIC01 Firmware Update Example ====\n");
5055
printf("==========================================\n");

examples/linux/spi_devkit/hello_world/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232

3333
int main(void)
3434
{
35+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
36+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
37+
setvbuf(stdout, NULL, _IONBF, 0);
38+
setvbuf(stderr, NULL, _IONBF, 0);
39+
3540
printf("======================================\n");
3641
printf("==== TROPIC01 Hello World Example ====\n");
3742
printf("======================================\n");

examples/linux/spi_devkit/identify_chip/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
int main(void)
2020
{
21+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
22+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
23+
setvbuf(stdout, NULL, _IONBF, 0);
24+
setvbuf(stderr, NULL, _IONBF, 0);
25+
2126
printf("==============================================\n");
2227
printf("==== TROPIC01 Chip Identification Example ====\n");
2328
printf("==============================================\n");

examples/linux/usb_devkit/fw_update/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ lt_ret_t get_fw_versions(lt_handle_t *lt_handle)
4545

4646
int main(void)
4747
{
48+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
49+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
50+
setvbuf(stdout, NULL, _IONBF, 0);
51+
setvbuf(stderr, NULL, _IONBF, 0);
52+
4853
printf("==========================================\n");
4954
printf("==== TROPIC01 Firmware Update Example ====\n");
5055
printf("==========================================\n");

examples/linux/usb_devkit/hello_world/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232

3333
int main(void)
3434
{
35+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
36+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
37+
setvbuf(stdout, NULL, _IONBF, 0);
38+
setvbuf(stderr, NULL, _IONBF, 0);
39+
3540
printf("======================================\n");
3641
printf("==== TROPIC01 Hello World Example ====\n");
3742
printf("======================================\n");

examples/linux/usb_devkit/identify_chip/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
int main(void)
2020
{
21+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
22+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
23+
setvbuf(stdout, NULL, _IONBF, 0);
24+
setvbuf(stderr, NULL, _IONBF, 0);
25+
2126
printf("==============================================\n");
2227
printf("==== TROPIC01 Chip Identification Example ====\n");
2328
printf("==============================================\n");

examples/model/hello_world/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131

3232
int main(void)
3333
{
34+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
35+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
36+
setvbuf(stdout, NULL, _IONBF, 0);
37+
setvbuf(stderr, NULL, _IONBF, 0);
38+
3439
printf("======================================\n");
3540
printf("==== TROPIC01 Hello World Example ====\n");
3641
printf("======================================\n");

examples/model/hw_wallet/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,11 @@ static int session3(lt_handle_t *h)
793793

794794
int main(void)
795795
{
796+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
797+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
798+
setvbuf(stdout, NULL, _IONBF, 0);
799+
setvbuf(stderr, NULL, _IONBF, 0);
800+
796801
printf("==========================================\n");
797802
printf("==== TROPIC01 Hardware Wallet Example ====\n");
798803
printf("==========================================\n");

examples/model/mac_and_destroy/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ static lt_ret_t PIN_entry_check(lt_handle_t *h, const uint8_t *PIN, const uint8_
523523

524524
int main(void)
525525
{
526+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
527+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
528+
setvbuf(stdout, NULL, _IONBF, 0);
529+
setvbuf(stderr, NULL, _IONBF, 0);
530+
526531
printf("==========================================\n");
527532
printf("==== TROPIC01 Mac and Destroy Example ====\n");
528533
printf("==========================================\n");

examples/model/separate_api/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333

3434
int main(void)
3535
{
36+
// Cosmetics: Disable buffering to keep output in order. You do not need to do this in your app if you don't care
37+
// about stdout/stderr output being shuffled or you use stdout only (or different output mechanism altogether).
38+
setvbuf(stdout, NULL, _IONBF, 0);
39+
setvbuf(stderr, NULL, _IONBF, 0);
40+
3641
printf("========================================\n");
3742
printf("==== TROPIC01 Separate API Example ====\n");
3843
printf("========================================\n");

0 commit comments

Comments
 (0)