{"id":21747338,"url":"https://github.com/mpaland/decom","last_synced_at":"2026-02-23T06:01:49.097Z","repository":{"id":71372482,"uuid":"2118307","full_name":"mpaland/decom","owner":"mpaland","description":"decom - unified DEvice COMmunication","archived":false,"fork":false,"pushed_at":"2021-06-01T11:49:57.000Z","size":207,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T06:53:22.309Z","etag":null,"topics":["application-layer","communication-layer","iso-tp","iso15765","osi-model","overlapped-io","protocol-layer","rs232","serialport","stack","tcp-ip","usb-hid","windows"],"latest_commit_sha":null,"homepage":"http://decom.io","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpaland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-07-28T12:20:48.000Z","updated_at":"2023-02-05T00:26:37.000Z","dependencies_parsed_at":"2023-03-07T15:45:35.231Z","dependency_job_id":null,"html_url":"https://github.com/mpaland/decom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mpaland/decom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaland%2Fdecom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaland%2Fdecom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaland%2Fdecom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaland%2Fdecom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpaland","download_url":"https://codeload.github.com/mpaland/decom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaland%2Fdecom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29738513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T04:51:08.365Z","status":"ssl_error","status_checked_at":"2026-02-23T04:49:15.865Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-layer","communication-layer","iso-tp","iso15765","osi-model","overlapped-io","protocol-layer","rs232","serialport","stack","tcp-ip","usb-hid","windows"],"created_at":"2024-11-26T08:08:43.093Z","updated_at":"2026-02-23T06:01:49.084Z","avatar_url":"https://github.com/mpaland.png","language":"C++","readme":"decom\r\n==================\r\n\r\n\r\nThis is the decom (**DE**vice **COM**munication) library.  \r\ndecom is a universal, cross platform, NON BLOCKING, high performance c++ communication library.\r\nIt is intended to be a minimalistic abstraction of the OSI layer model.\r\n\r\n\r\n## Design goals:\r\n- CLEAN code without any warnings on highest compiler level (4), LINT checked\r\n- Production/industrial/automotive code quality\r\n- Cross platform and embedded support\r\n- Header only, no modules\r\n- ONLY usage of standard C++, (C++11) and the STL library\r\n- ONLY usage of standard stdint.h (cstdint) and bool datatypes\r\n- NO other external libraries nor other platform dependencies except for util and communication layers which have architecture dependent folders (windows, linux etc.) because they must touch the hardware, OS API or vendor libs\r\n- Own static/pool message memory management - NO usage of any dynamic memory allocation\r\n- Zero copy of message data - if possible\r\n\r\n### Usage of STL containers\r\nIn the moment, some decom classes use STL containers like `\u003cvector\u003e`.  \r\nOn embedded systems special STL libs like \"ustl\" may be used.\r\nIn later versions, any usage of STL containers should be avoided due to dynamic memory management, which makes decom not suitable for automotive and small embedded applications.\r\n\r\n\r\n## Class overview\r\nThe following layer classification is used:\r\n\r\n![](https://cdn.rawgit.com/mpaland/decom/master/docs/layer.svg)\r\n\r\nThe decom stack consists of exactly one `com` (communicator), one `dev` (device) and any number of `prot`s (protocols).  \r\nInteraction between the layers is done by the following 5 decom standard interface functions:\r\n\r\n- `open()`\r\n  Open this layer to send/receive data.\r\n- `close()`\r\n  Close this layer.\r\n- `send()`\r\n  Called by the upper layer to send data to this layer.\r\n- `receive()`\r\n  Called by the lower layer to pass received data to this layer.\r\n- `indication()`\r\n  Called by the lower layer to indicate a status/error condition to this layer.\r\n\r\nThese functions MUST be implemented by every layer.\r\nEach layer can have further specific API functions to set layer specific protocol params like baudrate, timings, flow control etc. e.g. and can have a special param ctor(s).  \r\nWhy is there only one indication function in device direction? An indication function in com direction is not necessary because in many protocols incoming data can't be controlled or throtteled. The upper layers just have to deal with this and can't say the network to slow down or halt. \r\n\r\n\r\n### Device layer\r\nThis is the top most layer, often referred as the application layer (7) in OSI model.\r\nThis upper layer has only one interface to its lower layer and device specific functions which are used by the application (like read() or write()).\r\nThe namespace for devices is `decom::dev`.\r\n\r\n### Protocol layer\r\nThis layer has two interfaces. One to the upper layer and one to the lower layer. It's layer (3) to (6) in OSI model.\r\nTypically a protocol layer does clothing, stripping, checksum calculations, flow control etc.\r\nAny desired count of protocol layers can be chained together.\r\nProtocols may be inserted/deleted dynamically out of the stack. Dynamic object creation is supported.\r\nTry to avoid using threads in protocol layers cause not all platforms may support threads, use `util::timer` instead.\r\nThe namespace for protocols is `decom::prot`.\r\n\r\n### Communication layer\r\nThis is the lowest OSI layer (2). It has only one interface to an upper layer and sends/receives data to/from the hardware or OS API/HAL.\r\nThis layer is arcitecture dependent.\r\nThe namespace for communicators is `decom::com`.\r\n\r\n\r\n### msg class\r\ndecom stores all communication data in a special `msg` class. The `msg` class itself stores data in one or more pages, provided by a static msg pool.\r\nThe `msg` class has all functions and iterators of a normal STL container class. It's very similar to the 'deque' container, but has some major advantages like static memory management, data copies by reference counting etc.\r\n\r\n\r\n## Stack creation\r\nThe stack is always created bottom-top - meaning bottom (com) layer FIRST to top (dev) layer last.\r\nDynamic protocol generation, binding and unbinding (layer delete) is supported.\r\nDue to this mechanism it is possible to insert, for example, a file transfer protocol like\r\nxmodem between a device and a communication port.\r\n\r\n\r\nThe minimalistic stack is a device bound to a communication class without any protocol:\r\n\r\n```c++\r\n// include the necessary headers, include path must include the 'decom' folder\r\n#include \"prot/prot_debug.h\"\r\n#include \"com/com_serial.h\"\r\n#include \"dev/dev_generic.h\"\r\n\r\n// create a mini stack for RS232 communication\r\ndecom::com::serial  ser(9600U);   // use 9600 baud\r\ndecom::prot::debug  dbg(\u0026ser);    // debug layer\r\ndecom::dev::generic dev(\u0026dbg);\r\n\r\n// then use the stack\r\ndev.open(\"COM1\");       // open the COM1\r\ndev.write(...);         // write something to device\r\ndev.read(...);          // read something from device\r\ndev.close();            // close device (and implicit close the rest of the stack)\r\n```\r\n\r\nExample for a more complex stack creation with 4 chained protocols:\r\n\r\n```c++\r\n// create the stack\r\ndecom::com::serial   ser(115200);           // layer2 - 115 kBaud and default params\r\ndecom::prot::ppp     ppp1(\u0026ser);            // layer2 - create layer 2 tranport protocol\r\ndecom::prot::test1   prot1(\u0026ppp1);          // layer3 - create layer 3 routing protocol\r\ndecom::prot::test2   prot2(\u0026prot1, p1, p2); // layer4 - create layer 4 transport protocol with additional params P1 and P2\r\ndecom::prot::session sess(\u0026prot2);          // layer5 - create layer 5 session protocol\r\ndecom::dev::generic  dev(\u0026sess);            // layer7 - create generic device and bind to session protcol\r\n\r\n// use the stack\r\ndev.open(\"COM2\");        // open COM2 (and implicit open the rest of the stack)\r\ndev.write(...);          // write something to device\r\ndev.read(...);           // read something from device\r\ndev.close();             // close device (and implicit close the rest of the stack)\r\n```\r\n\r\n\r\n## Contributing\r\n\r\n1. Create an issue and describe your idea\r\n2. [Fork it](https://github.com/mpaland/decom/fork)\r\n3. Create your feature branch (`git checkout -b my-new-feature`)\r\n4. Commit your changes (`git commit -am 'Add some feature'`)\r\n5. Publish the branch (`git push origin my-new-feature`)\r\n6. Create a new Pull Request\r\n7. Profit! :white_check_mark:\r\n\r\n\r\n## License\r\n\r\ndecom is released under the [MIT license](http://www.opensource.org/licenses/MIT).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpaland%2Fdecom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpaland%2Fdecom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpaland%2Fdecom/lists"}