开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 0

蒙蒙plus/error_code

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
main
分支 (1)
main
main
分支 (1)
main
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
main
分支 (1)
main
error_code
/
error_code.c
error_code
/
error_code.c
error_code.c 3.02 KB
一键复制 编辑 原始数据 按行查看 历史
蒙蒙plus 提交于 2023年12月13日 15:23 +08:00 . add code
/**
* @file error_code.c
* @author mengplus (chengmeng_2@outlook.com)
* @brief
* @version 0.1
* @date 2023年12月13日
*
* @copyright Copyright (c) 2023
*
*/
#include "error_code.h"
#include <time.h>
// 全局的错误码链表头部
static error_code_t error_code_list_head;
// 在 error_code.c 文件中
static int is_duplicate_code(uint32_t code)
{
error_code_t *current_error = error_code_list_head.next;
while (current_error != NULL)
{
if (current_error->code == code)
{
return 1; // 错误码重复
}
current_error = current_error->next;
}
return 0; // 错误码唯一
}
void error_code_init()
{
// 初始化错误码链表头部
error_code_list_head.prev = NULL;
error_code_list_head.next = NULL;
error_code_list_head.code = 0;
}
uint16_t error_code_register(error_code_t *obj)
{
// 检查是否已存在相同错误码
if (is_duplicate_code(obj->code))
{
return 1; // 错误码重复,注册失败
}
// 在链表头部插入新的错误码对象
obj->prev = NULL;
obj->next = error_code_list_head.next;
if (error_code_list_head.next != NULL)
{
error_code_list_head.next->prev = obj;
}
error_code_list_head.next = obj;
obj->cnt = 0;
obj->err_cnt = 0;
obj->err_st = 0;
obj->err_ed = 0;
return 0; // 注册成功
}
// 在 error_code.c 源文件中添加移除接口的实现
uint16_t error_code_unregister(error_code_t *obj)
{
if (obj == NULL)
{
return 1; // 无效的错误码对象
}
// 从链表中移除该错误码对象
if (obj->prev != NULL)
{
obj->prev->next = obj->next;
}
else
{
// obj 是链表头部
error_code_list_head.next = obj->next;
}
if (obj->next != NULL)
{
obj->next->prev = obj->prev;
}
// 释放可能的资源,比如动态分配的内存
return 0; // 移除成功
}
error_code_t *error_code_get_list()
{
return error_code_list_head.next;
}
error_code_t *error_code_get_next_list(const error_code_t *item)
{
return item->next;
}
uint8_t error_code_set_flag(error_code_t *obj)
{
if (obj->cnt == 0)
{
obj->err_st = time(NULL);
}
// 设置错误标志
if (!error_code_is_error(obj))
{
obj->cnt++;
}
return 0; // 操作成功
}
void error_code_clear_flag(error_code_t *obj)
{
if (error_code_is_error(obj))
{
obj->err_cnt++;
}
// 清除错误标志
obj->cnt = 0; // 设置错误结束标志
}
uint8_t error_code_is_error(error_code_t *obj)
{
// 检查是否发生错误
return obj->cnt_max <= obj->cnt;
}
error_code_t *error_code_find(uint32_t code)
{
error_code_t *current_error = error_code_list_head.next;
while (current_error != NULL)
{
if (current_error->code == code)
{
return current_error; // 找到对应的错误码对象
}
current_error = current_error->next;
}
return NULL; // 未找到对应的错误码对象
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

设备故障码管理框架
暂无标签
Apache-2.0
使用 Apache-2.0 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/mengplus/error_code.git
git@gitee.com:mengplus/error_code.git
mengplus
error_code
error_code
main
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /