小编fed*_*di 的帖子

七星输出

我是 coccinelle 的初学者,并尝试运行我的第一个示例。

目前我正在按照本文的步骤进行操作

  1. 我创建了c文件
  2. 我创建了 coccinelle 脚本
  3. 我运行它使用

    $ spatch -sp_file test.cocci test.c
    
    Run Code Online (Sandbox Code Playgroud)

在终端中,我得到了文章中提到的预期结果

--- test.c
+++ /tmp/cocci-output-17416-b5450d-test.c
@@ -7,7 +7,7 @@ main(int argc, char *argv[])
         char *buf;

         /* allocate memory */
-        buf = alloca(bytes);
+        buf = malloc(bytes);

         return 0;
 }
Run Code Online (Sandbox Code Playgroud)

但是,c 文件没有按预期更改。

任何机构都可以告诉我在哪里可以获得脚本所做的更改?

c coccinelle

5
推荐指数
1
解决办法
149
查看次数

Linux 从 UART 读取数据

我想从 UART 读取数据,我按照本教程进行操作,写入功能按预期工作,但是我在读取功能方面遇到问题:

这是uart_init函数:

void uart_init()
{
 printf("\n +----------------------------------+");
 printf("\n |        Serial Port Write         |");
 printf("\n +----------------------------------+");

/*------------------------------- Opening the Serial Port -------------------------------*/

  fd = open("/dev/ttyUSB0",O_RDWR | O_NOCTTY| O_SYNC);      /* !!blocks the read  */
                                                            /* O_RDWR Read/Write access to serial port           */
                                                            /* O_NOCTTY - No terminal will control the process   */
                                                            /* O_NDELAY -Non Blocking Mode,Does not care about-  */
                                                            /* -the status of DCD line,Open() returns immediatly */                                        
                                
 if(fd == -1)                                               /* Error Checking */
  printf("\n …
Run Code Online (Sandbox Code Playgroud)

c linux uart

3
推荐指数
1
解决办法
2万
查看次数

为什么不在中断中使用互斥锁

我已经通过了这篇文章,我注意到在 Clifford 的回答中,他说我们不应该在中断中使用互斥锁,我知道在中断中我们必须避免过多的指令和延迟 ext...但我不是很清楚关于原因,任何人都可以向我澄清我们必须避免这种情况的原因吗?

如果我们想在 2 个中断驱动线程之间建立同步通信,如果不允许使用互斥锁,还有什么其他机制可以使用?

embedded multithreading interrupt

2
推荐指数
1
解决办法
7425
查看次数

标签 统计

c ×2

coccinelle ×1

embedded ×1

interrupt ×1

linux ×1

multithreading ×1

uart ×1