Skip to content

Instantly share code, notes, and snippets.

## 一.引言
### 1. 编写目的(阐明编写详细设计说明书的目的,指明读者对象。)
### 2. 项目背景(应包括项目的来源和主管部门等。)
### 3. 定义(列出文档中用到的专门术语定义和缩写词的原意。)
### 4. 参考资料(列出这些资料的作者、标题、编号、发表日期、出版单位或资料来源,可包括:(1)项目的计划任务书,合同或批文;(2)项目开发计划;(3)需求规格说明书;(3)概要设计说明书;(4)测试计划(初稿);(5)用户操作手册(初稿);(5)文档所引用的其他资料、软件开发标准或规范。)
## 二.总体设计
### 1.需求概述
@ahappyforest
ahappyforest / DebugTransportModuleJtag.v
Created January 15, 2018 16:59
DebugTransportModuleJtag.v
module DebugTransportModuleJtag (
//JTAG Interface
jtag_TDI,
jtag_TDO,
jtag_TCK,
jtag_TMS,
jtag_TRST,
@ahappyforest
ahappyforest / iptables
Created January 20, 2016 08:21
iptables for ss_redir+chinadns+dnsmasq
#!/bin/sh /etc/rc.common
START=95
start() {
# shadowsocks rules
iptables -t nat -N SHADOWSOCKS
# START
@ahappyforest
ahappyforest / print_r2.lua
Created March 27, 2015 05:27
version 2 for print_r
function print_r2(data, depth)
local depth = depth or 3
local cstring = "";
local top_flag = true
@ahappyforest
ahappyforest / print_r.lua
Created March 25, 2015 09:20
print lua table as lua style
function print_r(data)
local cstring = "";
local function table_len(t)
local i = 0
for k, v in pairs(t) do
i = i + 1
end
return i
在tinyos中, call command和signal event只是异步的基础设施, 当call command以及signal event时, 事实上该command和event是被同步调用的。 真正的异步是通过中断做的。
在tinyos中存在两条线, 一条是同步, 一条是异步, 中断和同步代码的通信是通过task进行的。
在中断中, 你可以直接signal async event, 但是如果对实时性没有要求, 可以在中断中用task。
https://g.xfg.io/search?newwindow=1&q=%s&gws_rd=ssl
int i;
for (i = 0;i < connection->msg.len * 2;i++) {
unsigned char c = (unsigned char *)connection->msg.data[(i & 0xf) | ((i & 0xffffffe0)>>1)];
if ((i & 15) == 0) printf("\n");
if ((i & 31) < 16) {
printf("%02x ", c);
} else {
if (c < 0x20) {
printf(".");
} else {
@ahappyforest
ahappyforest / mushroom_serial.txt
Created February 20, 2014 15:30
mushroom serial operation
while (1) {
每次总是先发送命令, 再读取回应, 因此这里也是按照这个顺序:
把串口操作看作是一个command和一个response组成, command是一个结构体, 不但包含待发送的数据, 还包含对应的message_queue指针, 上层的请求首先会被排队, 然后这个线程从队列中取出一个command开始发送。
0. 从队列中取出一个command
1. 发送command
2. 接收ack(这里严格按照超时来做, 因为有可能因为串口原因, 收不到ack)
3. 判断ack是否正确
4. 通知上层来响应这个ack的行为(将数据打包成response, 发送给message_queue)
message MessageHeader0x01
{
required int32 message_id = 1;
optional int32 session = 2;
optional HeaderPayLoad data;
message HeaderPayLoad {
required int32 birth_type;
required int32 fd;
}