@mytechtoday/augment-extensions 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
- package/augment-extensions/coding-standards/c/LICENSE +22 -0
- package/augment-extensions/coding-standards/c/README.md +167 -0
- package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
- package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
- package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
- package/augment-extensions/coding-standards/c/config/schema.json +244 -0
- package/augment-extensions/coding-standards/c/docs/API.md +613 -0
- package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
- package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
- package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
- package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
- package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
- package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
- package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
- package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
- package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
- package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
- package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
- package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
- package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
- package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
- package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
- package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
- package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
- package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
- package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
- package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
- package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
- package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
- package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
- package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
- package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
- package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
- package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
- package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
- package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
- package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
- package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
- package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
- package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
- package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
- package/augment-extensions/coding-standards/c/module.json +149 -0
- package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
- package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
- package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
- package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
- package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
- package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
- package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
- package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
- package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
- package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
- package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
- package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
- package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
- package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
- package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
- package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
- package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
- package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
- package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
- package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
- package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
- package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
- package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
- package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
- package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
- package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
- package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
- package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
- package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
- package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
- package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
- package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
- package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
- package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
- package/augment-extensions/coding-standards/go/README.md +200 -0
- package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
- package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
- package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
- package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
- package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
- package/augment-extensions/coding-standards/go/config/schema.json +110 -0
- package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
- package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
- package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
- package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
- package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
- package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
- package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
- package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
- package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
- package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
- package/augment-extensions/coding-standards/go/module.json +139 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
- package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
- package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
- package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
- package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
- package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
- package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
- package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
- package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
- package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
- package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
- package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
- package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
- package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
- package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
- package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
- package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
- package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
- package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
- package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
- package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
- package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
- package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
- package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
- package/cli/dist/analysis/ast-parser.d.ts +47 -0
- package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
- package/cli/dist/analysis/ast-parser.js +161 -0
- package/cli/dist/analysis/ast-parser.js.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.js +189 -0
- package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.js +237 -0
- package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
- package/cli/dist/analysis/index.d.ts +9 -0
- package/cli/dist/analysis/index.d.ts.map +1 -0
- package/cli/dist/analysis/index.js +25 -0
- package/cli/dist/analysis/index.js.map +1 -0
- package/cli/dist/analysis/security-scanner.d.ts +11 -0
- package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
- package/cli/dist/analysis/security-scanner.js +294 -0
- package/cli/dist/analysis/security-scanner.js.map +1 -0
- package/cli/dist/analysis/types.d.ts +151 -0
- package/cli/dist/analysis/types.d.ts.map +1 -0
- package/cli/dist/analysis/types.js +6 -0
- package/cli/dist/analysis/types.js.map +1 -0
- package/cli/dist/cli.js +24 -0
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/code-analysis.d.ts +11 -0
- package/cli/dist/commands/code-analysis.d.ts.map +1 -0
- package/cli/dist/commands/code-analysis.js +412 -0
- package/cli/dist/commands/code-analysis.js.map +1 -0
- package/modules.md +99 -3
- package/package.json +14 -2
- package/cli/dist/commands/agent.d.ts +0 -37
- package/cli/dist/commands/agent.d.ts.map +0 -1
- package/cli/dist/commands/agent.js +0 -222
- package/cli/dist/commands/agent.js.map +0 -1
- package/cli/dist/commands/beads.d.ts +0 -64
- package/cli/dist/commands/beads.d.ts.map +0 -1
- package/cli/dist/commands/beads.js +0 -377
- package/cli/dist/commands/beads.js.map +0 -1
- package/cli/dist/commands/change.d.ts +0 -54
- package/cli/dist/commands/change.d.ts.map +0 -1
- package/cli/dist/commands/change.js +0 -243
- package/cli/dist/commands/change.js.map +0 -1
- package/cli/dist/commands/clean.d.ts +0 -15
- package/cli/dist/commands/clean.d.ts.map +0 -1
- package/cli/dist/commands/clean.js +0 -63
- package/cli/dist/commands/clean.js.map +0 -1
- package/cli/dist/commands/clone.d.ts +0 -15
- package/cli/dist/commands/clone.d.ts.map +0 -1
- package/cli/dist/commands/clone.js +0 -49
- package/cli/dist/commands/clone.js.map +0 -1
- package/cli/dist/commands/config.d.ts +0 -33
- package/cli/dist/commands/config.d.ts.map +0 -1
- package/cli/dist/commands/config.js +0 -166
- package/cli/dist/commands/config.js.map +0 -1
- package/cli/dist/commands/context.d.ts +0 -38
- package/cli/dist/commands/context.d.ts.map +0 -1
- package/cli/dist/commands/context.js +0 -205
- package/cli/dist/commands/context.js.map +0 -1
- package/cli/dist/commands/create.d.ts +0 -18
- package/cli/dist/commands/create.d.ts.map +0 -1
- package/cli/dist/commands/create.js +0 -178
- package/cli/dist/commands/create.js.map +0 -1
- package/cli/dist/commands/diff.d.ts +0 -19
- package/cli/dist/commands/diff.d.ts.map +0 -1
- package/cli/dist/commands/diff.js +0 -104
- package/cli/dist/commands/diff.js.map +0 -1
- package/cli/dist/commands/doctor.d.ts +0 -14
- package/cli/dist/commands/doctor.d.ts.map +0 -1
- package/cli/dist/commands/doctor.js +0 -62
- package/cli/dist/commands/doctor.js.map +0 -1
- package/cli/dist/commands/export.d.ts +0 -28
- package/cli/dist/commands/export.d.ts.map +0 -1
- package/cli/dist/commands/export.js +0 -135
- package/cli/dist/commands/export.js.map +0 -1
- package/cli/dist/commands/import.d.ts +0 -23
- package/cli/dist/commands/import.d.ts.map +0 -1
- package/cli/dist/commands/import.js +0 -118
- package/cli/dist/commands/import.js.map +0 -1
- package/cli/dist/commands/prompt.d.ts +0 -45
- package/cli/dist/commands/prompt.d.ts.map +0 -1
- package/cli/dist/commands/prompt.js +0 -223
- package/cli/dist/commands/prompt.js.map +0 -1
- package/cli/dist/commands/spec.d.ts +0 -57
- package/cli/dist/commands/spec.d.ts.map +0 -1
- package/cli/dist/commands/spec.js +0 -279
- package/cli/dist/commands/spec.js.map +0 -1
- package/cli/dist/commands/stats.d.ts +0 -18
- package/cli/dist/commands/stats.d.ts.map +0 -1
- package/cli/dist/commands/stats.js +0 -85
- package/cli/dist/commands/stats.js.map +0 -1
- package/cli/dist/commands/task.d.ts +0 -65
- package/cli/dist/commands/task.d.ts.map +0 -1
- package/cli/dist/commands/task.js +0 -282
- package/cli/dist/commands/task.js.map +0 -1
- package/cli/dist/commands/template.d.ts +0 -17
- package/cli/dist/commands/template.d.ts.map +0 -1
- package/cli/dist/commands/template.js +0 -55
- package/cli/dist/commands/template.js.map +0 -1
- package/cli/dist/utils/agent-config.d.ts +0 -129
- package/cli/dist/utils/agent-config.d.ts.map +0 -1
- package/cli/dist/utils/agent-config.js +0 -297
- package/cli/dist/utils/agent-config.js.map +0 -1
- package/cli/dist/utils/beads-graph.d.ts +0 -17
- package/cli/dist/utils/beads-graph.d.ts.map +0 -1
- package/cli/dist/utils/beads-graph.js +0 -150
- package/cli/dist/utils/beads-graph.js.map +0 -1
- package/cli/dist/utils/beads-integration.d.ts +0 -112
- package/cli/dist/utils/beads-integration.d.ts.map +0 -1
- package/cli/dist/utils/beads-integration.js +0 -312
- package/cli/dist/utils/beads-integration.js.map +0 -1
- package/cli/dist/utils/beads-reporter.d.ts +0 -17
- package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
- package/cli/dist/utils/beads-reporter.js +0 -160
- package/cli/dist/utils/beads-reporter.js.map +0 -1
- package/cli/dist/utils/cache-manager.d.ts +0 -55
- package/cli/dist/utils/cache-manager.d.ts.map +0 -1
- package/cli/dist/utils/cache-manager.js +0 -150
- package/cli/dist/utils/cache-manager.js.map +0 -1
- package/cli/dist/utils/change-manager.d.ts +0 -70
- package/cli/dist/utils/change-manager.d.ts.map +0 -1
- package/cli/dist/utils/change-manager.js +0 -412
- package/cli/dist/utils/change-manager.js.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
- package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.js +0 -77
- package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
- package/cli/dist/utils/context-manager.d.ts +0 -96
- package/cli/dist/utils/context-manager.d.ts.map +0 -1
- package/cli/dist/utils/context-manager.js +0 -258
- package/cli/dist/utils/context-manager.js.map +0 -1
- package/cli/dist/utils/diff-engine.d.ts +0 -78
- package/cli/dist/utils/diff-engine.d.ts.map +0 -1
- package/cli/dist/utils/diff-engine.js +0 -233
- package/cli/dist/utils/diff-engine.js.map +0 -1
- package/cli/dist/utils/export-system.d.ts +0 -101
- package/cli/dist/utils/export-system.d.ts.map +0 -1
- package/cli/dist/utils/export-system.js +0 -289
- package/cli/dist/utils/export-system.js.map +0 -1
- package/cli/dist/utils/health-checker.d.ts +0 -66
- package/cli/dist/utils/health-checker.d.ts.map +0 -1
- package/cli/dist/utils/health-checker.js +0 -285
- package/cli/dist/utils/health-checker.js.map +0 -1
- package/cli/dist/utils/import-system.d.ts +0 -74
- package/cli/dist/utils/import-system.d.ts.map +0 -1
- package/cli/dist/utils/import-system.js +0 -317
- package/cli/dist/utils/import-system.js.map +0 -1
- package/cli/dist/utils/module-cloner.d.ts +0 -40
- package/cli/dist/utils/module-cloner.d.ts.map +0 -1
- package/cli/dist/utils/module-cloner.js +0 -136
- package/cli/dist/utils/module-cloner.js.map +0 -1
- package/cli/dist/utils/prompt-manager.d.ts +0 -90
- package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
- package/cli/dist/utils/prompt-manager.js +0 -302
- package/cli/dist/utils/prompt-manager.js.map +0 -1
- package/cli/dist/utils/spec-manager.d.ts +0 -65
- package/cli/dist/utils/spec-manager.d.ts.map +0 -1
- package/cli/dist/utils/spec-manager.js +0 -329
- package/cli/dist/utils/spec-manager.js.map +0 -1
- package/cli/dist/utils/stats-collector.d.ts +0 -74
- package/cli/dist/utils/stats-collector.d.ts.map +0 -1
- package/cli/dist/utils/stats-collector.js +0 -164
- package/cli/dist/utils/stats-collector.js.map +0 -1
- package/cli/dist/utils/template-engine.d.ts +0 -47
- package/cli/dist/utils/template-engine.d.ts.map +0 -1
- package/cli/dist/utils/template-engine.js +0 -204
- package/cli/dist/utils/template-engine.js.map +0 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file udp-multicast.c
|
|
3
|
+
* @brief Example UDP multicast sender and receiver
|
|
4
|
+
*
|
|
5
|
+
* This example demonstrates:
|
|
6
|
+
* - UDP multicast group management
|
|
7
|
+
* - Sending multicast packets
|
|
8
|
+
* - Receiving multicast packets
|
|
9
|
+
* - Socket options for multicast
|
|
10
|
+
* - Error handling
|
|
11
|
+
*
|
|
12
|
+
* Compile: gcc -Wall -Wextra -std=c11 -o udp-multicast udp-multicast.c
|
|
13
|
+
* Run sender: ./udp-multicast send 239.0.0.1 5000
|
|
14
|
+
* Run receiver: ./udp-multicast recv 239.0.0.1 5000
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#include <stdio.h>
|
|
18
|
+
#include <stdlib.h>
|
|
19
|
+
#include <string.h>
|
|
20
|
+
#include <unistd.h>
|
|
21
|
+
#include <errno.h>
|
|
22
|
+
#include <sys/types.h>
|
|
23
|
+
#include <sys/socket.h>
|
|
24
|
+
#include <netinet/in.h>
|
|
25
|
+
#include <arpa/inet.h>
|
|
26
|
+
#include <time.h>
|
|
27
|
+
|
|
28
|
+
#define BUFFER_SIZE 1024
|
|
29
|
+
#define MULTICAST_TTL 32
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @brief Create multicast sender socket
|
|
33
|
+
*/
|
|
34
|
+
static int create_multicast_sender(const char *group_addr, uint16_t port,
|
|
35
|
+
struct sockaddr_in *dest_addr) {
|
|
36
|
+
int sockfd;
|
|
37
|
+
unsigned char ttl = MULTICAST_TTL;
|
|
38
|
+
|
|
39
|
+
/* Create UDP socket */
|
|
40
|
+
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
41
|
+
if (sockfd < 0) {
|
|
42
|
+
perror("socket");
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Set multicast TTL */
|
|
47
|
+
if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) {
|
|
48
|
+
perror("setsockopt(IP_MULTICAST_TTL)");
|
|
49
|
+
close(sockfd);
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Setup destination address */
|
|
54
|
+
memset(dest_addr, 0, sizeof(*dest_addr));
|
|
55
|
+
dest_addr->sin_family = AF_INET;
|
|
56
|
+
dest_addr->sin_port = htons(port);
|
|
57
|
+
if (inet_aton(group_addr, &dest_addr->sin_addr) == 0) {
|
|
58
|
+
fprintf(stderr, "Invalid multicast address\n");
|
|
59
|
+
close(sockfd);
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
printf("Multicast sender created for %s:%u\n", group_addr, port);
|
|
64
|
+
return sockfd;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @brief Create multicast receiver socket
|
|
69
|
+
*/
|
|
70
|
+
static int create_multicast_receiver(const char *group_addr, uint16_t port) {
|
|
71
|
+
int sockfd;
|
|
72
|
+
struct sockaddr_in local_addr;
|
|
73
|
+
struct ip_mreq mreq;
|
|
74
|
+
int reuse = 1;
|
|
75
|
+
|
|
76
|
+
/* Create UDP socket */
|
|
77
|
+
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
78
|
+
if (sockfd < 0) {
|
|
79
|
+
perror("socket");
|
|
80
|
+
return -1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Allow multiple receivers on same port */
|
|
84
|
+
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) < 0) {
|
|
85
|
+
perror("setsockopt(SO_REUSEADDR)");
|
|
86
|
+
close(sockfd);
|
|
87
|
+
return -1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Bind to multicast port */
|
|
91
|
+
memset(&local_addr, 0, sizeof(local_addr));
|
|
92
|
+
local_addr.sin_family = AF_INET;
|
|
93
|
+
local_addr.sin_addr.s_addr = INADDR_ANY;
|
|
94
|
+
local_addr.sin_port = htons(port);
|
|
95
|
+
|
|
96
|
+
if (bind(sockfd, (struct sockaddr *)&local_addr, sizeof(local_addr)) < 0) {
|
|
97
|
+
perror("bind");
|
|
98
|
+
close(sockfd);
|
|
99
|
+
return -1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Join multicast group */
|
|
103
|
+
memset(&mreq, 0, sizeof(mreq));
|
|
104
|
+
if (inet_aton(group_addr, &mreq.imr_multiaddr) == 0) {
|
|
105
|
+
fprintf(stderr, "Invalid multicast address\n");
|
|
106
|
+
close(sockfd);
|
|
107
|
+
return -1;
|
|
108
|
+
}
|
|
109
|
+
mreq.imr_interface.s_addr = INADDR_ANY;
|
|
110
|
+
|
|
111
|
+
if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
|
|
112
|
+
perror("setsockopt(IP_ADD_MEMBERSHIP)");
|
|
113
|
+
close(sockfd);
|
|
114
|
+
return -1;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
printf("Multicast receiver joined group %s:%u\n", group_addr, port);
|
|
118
|
+
return sockfd;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @brief Run multicast sender
|
|
123
|
+
*/
|
|
124
|
+
static void run_sender(int sockfd, struct sockaddr_in *dest_addr) {
|
|
125
|
+
char buffer[BUFFER_SIZE];
|
|
126
|
+
int count = 0;
|
|
127
|
+
|
|
128
|
+
printf("Sending multicast messages (Ctrl+C to stop)...\n");
|
|
129
|
+
|
|
130
|
+
while (1) {
|
|
131
|
+
/* Create message with timestamp */
|
|
132
|
+
time_t now = time(NULL);
|
|
133
|
+
snprintf(buffer, sizeof(buffer),
|
|
134
|
+
"Multicast message #%d at %s", count++, ctime(&now));
|
|
135
|
+
|
|
136
|
+
/* Send multicast packet */
|
|
137
|
+
ssize_t sent = sendto(sockfd, buffer, strlen(buffer), 0,
|
|
138
|
+
(struct sockaddr *)dest_addr, sizeof(*dest_addr));
|
|
139
|
+
if (sent < 0) {
|
|
140
|
+
perror("sendto");
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
printf("Sent: %s", buffer);
|
|
145
|
+
sleep(2); /* Send every 2 seconds */
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @brief Run multicast receiver
|
|
151
|
+
*/
|
|
152
|
+
static void run_receiver(int sockfd) {
|
|
153
|
+
char buffer[BUFFER_SIZE];
|
|
154
|
+
struct sockaddr_in sender_addr;
|
|
155
|
+
socklen_t sender_len;
|
|
156
|
+
|
|
157
|
+
printf("Receiving multicast messages (Ctrl+C to stop)...\n");
|
|
158
|
+
|
|
159
|
+
while (1) {
|
|
160
|
+
sender_len = sizeof(sender_addr);
|
|
161
|
+
ssize_t received = recvfrom(sockfd, buffer, sizeof(buffer) - 1, 0,
|
|
162
|
+
(struct sockaddr *)&sender_addr, &sender_len);
|
|
163
|
+
|
|
164
|
+
if (received < 0) {
|
|
165
|
+
perror("recvfrom");
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
buffer[received] = '\0';
|
|
170
|
+
printf("Received from %s:%u: %s",
|
|
171
|
+
inet_ntoa(sender_addr.sin_addr),
|
|
172
|
+
ntohs(sender_addr.sin_port),
|
|
173
|
+
buffer);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @brief Main function
|
|
179
|
+
*/
|
|
180
|
+
int main(int argc, char *argv[]) {
|
|
181
|
+
int sockfd;
|
|
182
|
+
const char *mode, *group_addr;
|
|
183
|
+
uint16_t port;
|
|
184
|
+
|
|
185
|
+
/* Parse arguments */
|
|
186
|
+
if (argc != 4) {
|
|
187
|
+
fprintf(stderr, "Usage: %s <send|recv> <multicast_addr> <port>\n", argv[0]);
|
|
188
|
+
fprintf(stderr, "Example: %s send 239.0.0.1 5000\n", argv[0]);
|
|
189
|
+
fprintf(stderr, " %s recv 239.0.0.1 5000\n", argv[0]);
|
|
190
|
+
return EXIT_FAILURE;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
mode = argv[1];
|
|
194
|
+
group_addr = argv[2];
|
|
195
|
+
port = (uint16_t)atoi(argv[3]);
|
|
196
|
+
|
|
197
|
+
if (strcmp(mode, "send") == 0) {
|
|
198
|
+
/* Sender mode */
|
|
199
|
+
struct sockaddr_in dest_addr;
|
|
200
|
+
sockfd = create_multicast_sender(group_addr, port, &dest_addr);
|
|
201
|
+
if (sockfd < 0) {
|
|
202
|
+
return EXIT_FAILURE;
|
|
203
|
+
}
|
|
204
|
+
run_sender(sockfd, &dest_addr);
|
|
205
|
+
} else if (strcmp(mode, "recv") == 0) {
|
|
206
|
+
/* Receiver mode */
|
|
207
|
+
sockfd = create_multicast_receiver(group_addr, port);
|
|
208
|
+
if (sockfd < 0) {
|
|
209
|
+
return EXIT_FAILURE;
|
|
210
|
+
}
|
|
211
|
+
run_receiver(sockfd);
|
|
212
|
+
} else {
|
|
213
|
+
fprintf(stderr, "Invalid mode: %s (use 'send' or 'recv')\n", mode);
|
|
214
|
+
return EXIT_FAILURE;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
close(sockfd);
|
|
218
|
+
return EXIT_SUCCESS;
|
|
219
|
+
}
|
|
220
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Makefile for Real-Time Systems Examples
|
|
2
|
+
# Requires FreeRTOS or compatible RTOS
|
|
3
|
+
|
|
4
|
+
# FreeRTOS paths (adjust for your installation)
|
|
5
|
+
FREERTOS_DIR ?= /opt/FreeRTOS
|
|
6
|
+
FREERTOS_SRC = $(FREERTOS_DIR)/Source
|
|
7
|
+
FREERTOS_PORT = $(FREERTOS_SRC)/portable/GCC/ARM_CM3
|
|
8
|
+
|
|
9
|
+
CC = arm-none-eabi-gcc
|
|
10
|
+
CFLAGS = -Wall -Wextra -std=c11 -O2
|
|
11
|
+
CFLAGS += -mcpu=cortex-m3 -mthumb
|
|
12
|
+
CFLAGS += -DUSE_FREERTOS
|
|
13
|
+
CFLAGS += -I$(FREERTOS_SRC)/include
|
|
14
|
+
CFLAGS += -I$(FREERTOS_PORT)
|
|
15
|
+
CFLAGS += -I.
|
|
16
|
+
|
|
17
|
+
# Source files
|
|
18
|
+
SRCS = priority-scheduling.c deadline-monitoring.c
|
|
19
|
+
|
|
20
|
+
# For host compilation (testing structure only)
|
|
21
|
+
HOST_CC = gcc
|
|
22
|
+
HOST_CFLAGS = -Wall -Wextra -std=c11 -O2
|
|
23
|
+
|
|
24
|
+
.PHONY: all clean host-test
|
|
25
|
+
|
|
26
|
+
# Default target (requires RTOS)
|
|
27
|
+
all:
|
|
28
|
+
@echo "This requires FreeRTOS or compatible RTOS"
|
|
29
|
+
@echo "Set FREERTOS_DIR to your FreeRTOS installation"
|
|
30
|
+
@echo "Or use 'make host-test' for syntax checking"
|
|
31
|
+
|
|
32
|
+
# Host compilation for syntax checking
|
|
33
|
+
host-test:
|
|
34
|
+
$(HOST_CC) $(HOST_CFLAGS) -c priority-scheduling.c -o priority-scheduling.o
|
|
35
|
+
$(HOST_CC) $(HOST_CFLAGS) -c deadline-monitoring.c -o deadline-monitoring.o
|
|
36
|
+
@echo "Syntax check passed"
|
|
37
|
+
|
|
38
|
+
clean:
|
|
39
|
+
rm -f *.o *.elf *.bin
|
|
40
|
+
|
|
41
|
+
help:
|
|
42
|
+
@echo "Real-Time Systems Examples Makefile"
|
|
43
|
+
@echo "===================================="
|
|
44
|
+
@echo "Targets:"
|
|
45
|
+
@echo " all - Build for target (requires RTOS)"
|
|
46
|
+
@echo " host-test - Syntax check on host"
|
|
47
|
+
@echo " clean - Remove build artifacts"
|
|
48
|
+
@echo ""
|
|
49
|
+
@echo "Requirements:"
|
|
50
|
+
@echo " - FreeRTOS or compatible RTOS"
|
|
51
|
+
@echo " - ARM GCC toolchain (for embedded)"
|
|
52
|
+
@echo " - GCC (for host testing)"
|
|
53
|
+
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Real-Time Systems Examples
|
|
2
|
+
|
|
3
|
+
This directory contains real-time programming examples demonstrating RTOS concepts and deadline monitoring.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### 1. priority-scheduling.c
|
|
8
|
+
Priority-based task scheduling:
|
|
9
|
+
- Multiple tasks with different priorities
|
|
10
|
+
- Priority-based preemption
|
|
11
|
+
- Mutex with priority inheritance
|
|
12
|
+
- Periodic and aperiodic tasks
|
|
13
|
+
- Event-driven processing
|
|
14
|
+
|
|
15
|
+
**Key Concepts:**
|
|
16
|
+
- Higher priority tasks preempt lower priority
|
|
17
|
+
- Use `vTaskDelayUntil()` for periodic tasks
|
|
18
|
+
- Priority inheritance prevents priority inversion
|
|
19
|
+
- Event queues for aperiodic events
|
|
20
|
+
|
|
21
|
+
### 2. deadline-monitoring.c
|
|
22
|
+
Deadline monitoring and tracking:
|
|
23
|
+
- Execution time measurement
|
|
24
|
+
- Deadline miss detection
|
|
25
|
+
- WCET (Worst-Case Execution Time) tracking
|
|
26
|
+
- Task timing statistics
|
|
27
|
+
- Watchdog timer for enforcement
|
|
28
|
+
|
|
29
|
+
**Key Concepts:**
|
|
30
|
+
- Monitor execution time for each task instance
|
|
31
|
+
- Detect and log deadline misses
|
|
32
|
+
- Track min/max/average execution times
|
|
33
|
+
- Use watchdog timers for safety
|
|
34
|
+
|
|
35
|
+
## Building
|
|
36
|
+
|
|
37
|
+
### For FreeRTOS
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Set FreeRTOS path
|
|
41
|
+
export FREERTOS_DIR=/path/to/FreeRTOS
|
|
42
|
+
|
|
43
|
+
# Build (requires ARM toolchain)
|
|
44
|
+
make
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### For Host Testing (Syntax Check)
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Compile for syntax checking only
|
|
51
|
+
make host-test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## RTOS Integration
|
|
55
|
+
|
|
56
|
+
These examples are designed for FreeRTOS but can be adapted for:
|
|
57
|
+
- **Zephyr RTOS**: Replace FreeRTOS API with Zephyr equivalents
|
|
58
|
+
- **RTEMS**: Use RTEMS Classic API
|
|
59
|
+
- **VxWorks**: Use VxWorks task API
|
|
60
|
+
- **POSIX Real-Time**: Use pthread with real-time scheduling
|
|
61
|
+
|
|
62
|
+
## Real-Time Concepts
|
|
63
|
+
|
|
64
|
+
### Priority Scheduling
|
|
65
|
+
|
|
66
|
+
Tasks are scheduled based on priority:
|
|
67
|
+
```c
|
|
68
|
+
xTaskCreate(task_func, "Task", stack_size, NULL, PRIORITY_HIGH, NULL);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Priority levels (example):
|
|
72
|
+
- **High (3)**: Critical control loops, ISR handlers
|
|
73
|
+
- **Medium (2)**: Data processing, communication
|
|
74
|
+
- **Low (1)**: Background tasks, logging
|
|
75
|
+
|
|
76
|
+
### Deadline Monitoring
|
|
77
|
+
|
|
78
|
+
Monitor task execution time:
|
|
79
|
+
```c
|
|
80
|
+
uint32_t start = get_time_us();
|
|
81
|
+
/* Do work */
|
|
82
|
+
uint32_t end = get_time_us();
|
|
83
|
+
uint32_t execution_time = end - start;
|
|
84
|
+
|
|
85
|
+
if (execution_time > deadline) {
|
|
86
|
+
/* Deadline miss! */
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Priority Inheritance
|
|
91
|
+
|
|
92
|
+
Prevent priority inversion:
|
|
93
|
+
```c
|
|
94
|
+
/* Create mutex with priority inheritance */
|
|
95
|
+
SemaphoreHandle_t mutex = xSemaphoreCreateMutex();
|
|
96
|
+
|
|
97
|
+
/* Low priority task holding mutex inherits high priority */
|
|
98
|
+
xSemaphoreTake(mutex, timeout);
|
|
99
|
+
/* Critical section */
|
|
100
|
+
xSemaphoreGive(mutex);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Best Practices
|
|
104
|
+
|
|
105
|
+
1. **Task Design**
|
|
106
|
+
- Keep tasks simple and focused
|
|
107
|
+
- Use appropriate priorities
|
|
108
|
+
- Avoid blocking in high-priority tasks
|
|
109
|
+
- Use timeouts on all blocking calls
|
|
110
|
+
|
|
111
|
+
2. **Timing**
|
|
112
|
+
- Use `vTaskDelayUntil()` for periodic tasks
|
|
113
|
+
- Monitor execution times
|
|
114
|
+
- Set realistic deadlines
|
|
115
|
+
- Track WCET
|
|
116
|
+
|
|
117
|
+
3. **Synchronization**
|
|
118
|
+
- Use mutexes with priority inheritance
|
|
119
|
+
- Minimize critical sections
|
|
120
|
+
- Avoid nested locks
|
|
121
|
+
- Use queues for inter-task communication
|
|
122
|
+
|
|
123
|
+
4. **Resource Management**
|
|
124
|
+
- Allocate resources at initialization
|
|
125
|
+
- Avoid dynamic allocation in tasks
|
|
126
|
+
- Use static allocation when possible
|
|
127
|
+
- Clean up resources properly
|
|
128
|
+
|
|
129
|
+
## Common Pitfalls
|
|
130
|
+
|
|
131
|
+
1. **Priority Inversion**
|
|
132
|
+
```c
|
|
133
|
+
// WRONG - No priority inheritance
|
|
134
|
+
SemaphoreHandle_t sem = xSemaphoreCreateBinary();
|
|
135
|
+
|
|
136
|
+
// CORRECT - Use mutex with priority inheritance
|
|
137
|
+
SemaphoreHandle_t mutex = xSemaphoreCreateMutex();
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
2. **Missed Deadlines**
|
|
141
|
+
```c
|
|
142
|
+
// WRONG - No deadline monitoring
|
|
143
|
+
void task(void *params) {
|
|
144
|
+
while (1) {
|
|
145
|
+
do_work(); // How long does this take?
|
|
146
|
+
vTaskDelay(period);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// CORRECT - Monitor execution time
|
|
151
|
+
void task(void *params) {
|
|
152
|
+
while (1) {
|
|
153
|
+
uint32_t start = get_time_us();
|
|
154
|
+
do_work();
|
|
155
|
+
uint32_t elapsed = get_time_us() - start;
|
|
156
|
+
if (elapsed > deadline) {
|
|
157
|
+
log_deadline_miss();
|
|
158
|
+
}
|
|
159
|
+
vTaskDelay(period);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
3. **Blocking in High-Priority Tasks**
|
|
165
|
+
```c
|
|
166
|
+
// WRONG - Blocking indefinitely
|
|
167
|
+
void high_priority_task(void *params) {
|
|
168
|
+
while (1) {
|
|
169
|
+
xQueueReceive(queue, &data, portMAX_DELAY); // Bad!
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// CORRECT - Use timeout
|
|
174
|
+
void high_priority_task(void *params) {
|
|
175
|
+
while (1) {
|
|
176
|
+
if (xQueueReceive(queue, &data, pdMS_TO_TICKS(10)) == pdTRUE) {
|
|
177
|
+
process_data(&data);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Performance Metrics
|
|
184
|
+
|
|
185
|
+
Track these metrics for real-time tasks:
|
|
186
|
+
- **Execution time**: Min, max, average
|
|
187
|
+
- **Deadline misses**: Count and percentage
|
|
188
|
+
- **Jitter**: Variation in execution time
|
|
189
|
+
- **Response time**: Time from event to completion
|
|
190
|
+
- **CPU utilization**: Percentage of time busy
|
|
191
|
+
|
|
192
|
+
## References
|
|
193
|
+
|
|
194
|
+
- FreeRTOS Documentation: https://www.freertos.org/
|
|
195
|
+
- "Real-Time Systems" by Jane W. S. Liu
|
|
196
|
+
- "Hard Real-Time Computing Systems" by Giorgio Buttazzo
|
|
197
|
+
- Rate Monotonic Analysis (RMA)
|
|
198
|
+
- Earliest Deadline First (EDF) scheduling
|
|
199
|
+
|