{"id":13812712,"url":"https://github.com/marcinbor85/cAT","last_synced_at":"2025-05-14T22:31:01.108Z","repository":{"id":37387459,"uuid":"217711145","full_name":"marcinbor85/cAT","owner":"marcinbor85","description":"Plain C library for parsing AT commands for use in host devices.","archived":false,"fork":false,"pushed_at":"2023-12-20T14:29:55.000Z","size":317,"stargazers_count":410,"open_issues_count":13,"forks_count":78,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-19T07:39:00.880Z","etag":null,"topics":["at","atcmd","cat","commands","libcat","library","parser","static"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcinbor85.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","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}},"created_at":"2019-10-26T13:16:04.000Z","updated_at":"2024-11-18T12:39:16.000Z","dependencies_parsed_at":"2023-01-20T20:16:46.090Z","dependency_job_id":"dfeb02eb-578e-4f62-b758-2f449639b510","html_url":"https://github.com/marcinbor85/cAT","commit_stats":{"total_commits":188,"total_committers":9,"mean_commits":20.88888888888889,"dds":0.09042553191489366,"last_synced_commit":"84fdca960b8cbc8c4b5d87cd1805815ca2a27b52"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinbor85%2FcAT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinbor85%2FcAT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinbor85%2FcAT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinbor85%2FcAT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcinbor85","download_url":"https://codeload.github.com/marcinbor85/cAT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254239465,"owners_count":22037714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["at","atcmd","cat","commands","libcat","library","parser","static"],"created_at":"2024-08-04T04:00:54.721Z","updated_at":"2025-05-14T22:30:56.019Z","avatar_url":"https://github.com/marcinbor85.png","language":"C","readme":"[![Build Status](https://travis-ci.org/marcinbor85/cat.svg?branch=master)](https://travis-ci.org/marcinbor85/cat)\n# libcat (cAT)\nPlain C library for parsing AT commands for use in host devices.\n\n## Features\n* blazing fast, non-blocking, robust implementation\n* 100% static implementation (without any dynamic memory allocation)\n* very small footprint (both RAM and ROM)\n* support for READ, WRITE, TEST and RUN type commands\n* commands shortcuts (auto select best command candidate)\n* single request - multiple responses\n* unsolicited read/test command support\n* hold state for delayed responses for time-consuming tasks\n* high-level memory variables mapping arguments parsing\n* variables accessors (read and write, read only, write only)\n* automatic arguments types validating\n* automatic format test responses for commands with variables\n* CRLF and LF compatible\n* case-insensitive\n* dedicated for embedded systems\n* object-oriented architecture\n* separated interface for low-level layer\n* fully asynchronous input/output operations\n* multiplatform and portable\n* asynchronous api with event callbacks\n* print registered commands list feature\n* only two source files\n* wide unit tests\n\n## Build\n\nBuild and install:\n\n```sh\ncmake .\nmake\nmake test\nsudo make install\n```\n\n## Example basic demo posibilities\n\n```console\nAT+PRINT=?                                              # TEST command\n+PRINT=\u003cX:UINT8[RW]\u003e,\u003cY:UINT8[RW]\u003e,\u003cMESSAGE:STRING[RW]\u003e # Automatic response\nPrinting something special at (X,Y).                    # Automatic response\nOK                                                      # Automatic acknowledge\n\nAT+PRINT?                                               # READ command\n+PRINT=0,0,\"\"                                           # Automatic response\nOK                                                      # Automatic acknowledge\n\nAT+PRINT=xyz,-2                                         # WRITE command\nERROR                                                   # Automatic acknowledge\n\nAT+PRINT=1,2,\"test\"                                     # WRITE command\nOK                                                      # Automatic acknowledge\n\nAT+PRINT                                                # RUN command\nsome printing at (1,2) with text \"test\"                 # Manual response\nOK                                                      # Automatic acknowledge\n```\n\n## Example unsolicited demo posibilities\n\n```console\nAT+START=?                                              # TEST command\n+START=\u003cMODE:UINT32[WO]\u003e                                # Automatic response\nStart scanning after write (0 - wifi, 1 - bluetooth).   # Automatic response\nOK                                                      # Automatic acknowledge\n\nAT+START=0                                              # WRITE command\n+SCAN=-10,\"wifi1\"                                       # Unsolicited read response\n+SCAN=-50,\"wifi2\"                                       # Unsolicited read response\n+SCAN=-20,\"wifi3\"                                       # Unsolicited read response\nOK                                                      # Unsolicited acknowledge\n\nAT+START=1                                              # WRITE command\n+SCAN=-20,\"bluetooth1\"                                  # Unsolicited read response\nOK                                                      # Unsolicited acknowledge\n\nAT+SCAN=?                                               # TEST command\n+SCAN=\u003cRSSI:INT32[RO]\u003e,\u003cSSID:STRING[RO]\u003e                # Automatic response\nScan result record.                                     # Automatic response\nOK                                                      # Automatic acknowledge\n```\n\n## Usage\n\nDefine High-Level variables:\n\n```c\n\nstatic uint8_t x;\nstatic uint8_t y;\nstatic char msg[32];\n\nstatic struct cat_variable go_vars[] = {\n        {\n                .type = CAT_VAR_UINT_DEC, /* unsigned int variable */\n                .data = \u0026x,\n                .data_size = sizeof(x),\n                .write = x_write,\n                .name = \"X\",\n                .access = CAT_VAR_ACCESS_READ_WRITE,\n        },\n        {\n                .type = CAT_VAR_UINT_DEC, /* unsigned int variable */\n                .data = \u0026y,\n                .data_size = sizeof(y),\n                .write = y_write,\n                .access = CAT_VAR_ACCESS_READ_WRITE,\n        },\n        {\n                .type = CAT_VAR_BUF_STRING, /* string variable */\n                .data = msg,\n                .data_size = sizeof(msg),\n                .write = msg_write,\n                .access = CAT_VAR_ACCESS_READ_WRITE,\n        }\n};\n```\n\nDefine AT commands descriptor:\n\n```c\nstatic struct cat_command cmds[] = {\n        {\n                .name = \"TEST\",\n                .read = test_read, /* read handler for ATTEST? command */\n                .write = test_write, /* write handler for ATTEST={val} command */\n                .run = test_run /* run handler for ATTEST command */\n        },\n        {\n                .name = \"+NUM\",\n                .write = num_write, /* write handler for AT+NUM={val} command */\n                .read = num_read /* read handler for AT+NUM? command */\n        },\n        {\n                .name = \"+GO\",\n                .write = go_write, /* write handler for AT+GO={x},{y},{msg} command */\n                .var = go_vars, /* attach variables to command */\n                .var_num = sizeof(go_vars) / sizeof(go_vars[0]),\n                .need_all_vars = true\n        },\n        {\n                .name = \"RESTART\",\n                .run = restart_run /* run handler for ATRESTART command */\n        }\n};\n```\n\nDefine AT command parser descriptor:\n\n```c\n\nstatic char working_buf[128]; /* working buffer, must be declared manually */\n\nstatic struct cat_command_group cmd_group = {\n        .cmd = cmds,\n        .cmd_num = sizeof(cmds) / sizeof(cmds[0]),\n};\n\nstatic struct cat_command_group *cmd_desc[] = {\n        \u0026cmd_group\n};\n\nstatic struct cat_descriptor desc = {\n        .cmd_group = cmd_desc,\n        .cmd_group_num = sizeof(cmd_desc) / sizeof(cmd_desc[0]),\n\n        .buf = working_buf,\n        .buf_size = sizeof(working_buf),\n};\n```\n\nDefine IO low-level layer interface:\n\n```c\nstatic int write_char(char ch)\n{\n        putc(ch, stdout);\n        return 1;\n}\n\nstatic int read_char(char *ch)\n{\n        *ch = getch();\n        return 1;\n}\n\nstatic struct cat_io_interface iface = {\n        .read = read_char,\n        .write = write_char\n};\n```\n\nInitialize AT command parser and run:\n\n```c\nstruct cat_object at; /* at command parser object */\n\ncat_init(\u0026at, \u0026desc, \u0026iface, NULL); /* initialize at command parser object */\n\nwhile (1) {\n        cat_service(\u0026at) /* periodically call at command parser service */\n\n        ... /* other stuff, running in main loop */\n}\n\n```\n","funding_links":[],"categories":["Protocols"],"sub_categories":["Protocol Parsers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinbor85%2FcAT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcinbor85%2FcAT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinbor85%2FcAT/lists"}