Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for Carl
| Type | On... | Excerpt | Status | Date |
|---|---|---|---|---|
| Comment | Post #296682 |
So I guess an answer to the question is, that private encapsulation helps us achieve a program with loosely coupled classes, which is an objectively good thing. (more) |
— | about 19 hours ago |
| Edit | Post #296682 |
Post edited: |
— | about 20 hours ago |
| Edit | Post #296682 | Initial revision | — | about 21 hours ago |
| Question | — |
Why is private encapsulation "good" in (C) programming? I have read several times that it is implied that it is "good" programming style to have private encapsulation. But I'm curious to know what exactly makes it good. For example, the code below does not use private encapsulation because the user of the ring-buffer (main.c) has access to all the ri... (more) |
— | about 21 hours ago |
| Edit | Post #296652 |
Post edited: |
— | 7 days ago |
| Edit | Post #296652 |
Post edited: |
— | 7 days ago |
| Edit | Post #296652 | Initial revision | — | 7 days ago |
| Question | — |
Embedded C - memory pool types In embedded systems, dynamic memory allocation is discouraged (or forbidden) due to various reasons. A better idea is to statically allocate a chunk of memory whose size is known at compile time - this is called a memory pool. Then, during run time you can partition that chunk into smaller block... (more) |
— | 7 days ago |
| Comment | Post #296650 |
Thank you for your point on uart transmit interrupt routine. I had been so fixated on the uart receive routine (because in my opinion it is harder to get right) that I had completely neglected to ensure I had a robust transmit routine. (more) |
— | 7 days ago |
| Edit | Post #296642 |
Post edited: |
— | 8 days ago |
| Comment | Post #283890 |
In your `cstring.c` you use dynamic memory allocation to construct your `cstring` "object". Dynamic memory allocation is discouraged in embedded systems programming due to various reasons. Is there a way to have a `create` or `init` function without using `malloc` or other functions for dynamic m... (more) |
— | 9 days ago |
| Edit | Post #296642 |
Post edited: |
— | 9 days ago |
| Edit | Post #296642 | Initial revision | — | 9 days ago |
| Question | — |
Declaring a callback function in `usart.h`, using it in `usart.c` but defining it in `main.c` I have written a generic device driver for a uart peripheral with a source file `usart.c` and a header file `usart.h`. I don't want a user of these files have to tamper with them. I want to use the usart peripheral in an interrupt driven fashion, where I store the incoming byte in a ring-buffer,... (more) |
— | 9 days ago |
| Comment | Post #290881 |
Are there any benefits of using an “optional_tag” for a typedef’ed struct? Like is there a benefit to using the tag here ` typedef struct point_tag { int x, int y} point; `? (more) |
— | 10 days ago |
| Edit | Post #296623 |
Post edited: |
— | 15 days ago |
| Edit | Post #296623 | Initial revision | — | 15 days ago |
| Question | — |
Checking if an array is partially initialized at compile-time I have the following code in my project ```C typedef enum { RELAYCHANNELPIN5, RELAYCHANNELPIN6, RELAYCHANNELPIN7, RELAYCHANNELPIN8, RELAYCHANNELSN } relaychannelpint; static const uint8t relayarr[] = { [RELAYCHANNELPIN5] = PJ4, [RELAYCHANNELPIN6] = PJ5, [RELAYCHANNELPIN7] = PJ6, [REL... (more) |
— | 15 days ago |
| Edit | Post #296506 | Initial revision | — | about 1 month ago |
| Question | — |
Avoiding checking opcode multiple times in state machine for embedded system I am implementing a state machine for an electrical relay control board and am trying to follow the principles/structure presented by Lundin here for doing that in C. My machine has currently four states: init, poll, status, and switch. In the poll state the microcontroller waits to receive an o... (more) |
— | about 1 month ago |
| Edit | Post #296419 |
Post edited: |
— | about 2 months ago |
| Edit | Post #296419 | Initial revision | — | about 2 months ago |
| Question | — |
Is there any reason not to use the latest version of MISRA C guidelines? I am contemplating on purchasing a personal copy of the MISRA C guideline document. Looking at their website shows several different versions - MISRA C:2025, MISRA C:2012 3rd ed., MISRA C:2004, etc. Is there any reason not to use the latest version of the document? Is there something to be awa... (more) |
— | about 2 months ago |
| Edit | Post #282566 |
Post edited: Change Wunused_result to Wunused-result |
— | 2 months ago |
| Edit | Post #296383 |
Post edited: |
— | 2 months ago |
| Edit | Post #296383 |
Post edited: |
— | 2 months ago |
| Edit | Post #296383 |
Post edited: |
— | 2 months ago |
| Edit | Post #296383 | Initial revision | — | 2 months ago |
| Question | — |
Extern keyword in C and proper way to use extern variables in embedded systems I have an 8-bit microcontroller with 100 pins. Each pin belongs to a port with a unique address and each pin has a number from 0 to 7. I want to create a scheme where in the code each pin is a struct that carries the pin's port address and number with it. I have defined a `pint` struct in `gpio.h... (more) |
— | 2 months ago |
| Suggested Edit | Post #282566 |
Suggested edit: Change Wunused_result to Wunused-result (more) |
helpful | 2 months ago |
| Comment | Post #295840 |
Thank you Lundin - I hadn't seen that other answer to the do{} while(0) macro construct. (more) |
— | 5 months ago |
| Comment | Post #295840 |
Thank you for your answer, Lundin. A follow-up question: Would you advice against a macro that implements the code you propose for setting a bit? Something like this
```
#define BIT_SET(REG, BIT) \
do { \
uint8_t some_register = (REG); \
... (more) |
— | 6 months ago |
| Edit | Post #295834 |
Post edited: |
— | 6 months ago |
| Edit | Post #295834 |
Post edited: |
— | 6 months ago |
| Edit | Post #295834 | Initial revision | — | 6 months ago |
| Question | — |
Making code MISRA C compliant makes code less readable. I've started rewriting some of my old C-code projects such that they comply with the MISRA C standards. I've noticed that literally all of them break rule 10.3 from the C:2012 guideline document: > Rule 10.3 The value of an expression shall not be assigned to an object with a narrower essential ... (more) |
— | 6 months ago |
| Edit | Post #295667 |
Post edited: |
— | 6 months ago |
| Comment | Post #295663 |
What is a "caller"? For example a statement like "A function may take parameters and it may return a value to the caller." does that mean for a line code like this ```double a = sqrt(2);``` is ```a``` then the caller? (more) |
— | 6 months ago |
| Edit | Post #295667 | Initial revision | — | 6 months ago |
| Question | — |
Alternative to boolean type for embedded C (ATmega2560) I'm working on writing drivers for the peripherals in my ATmega2560 microcontroller. One of these is a USART which has the option of being double speed or normal speed. If this was C for the PC I would use `````` to create a boolean member of the USART struct and write my header and source file a... (more) |
— | 6 months ago |
