我们正在编程一个ST269微控制器,它有两个红外距离传感器.为了校准这些传感器,我们为每个传感器制作了一个表格,其中包括我们测量的距离以及我们从ADC获得的相应值.
现在我们要使用一个函数来近似它们之间的值.因此我们将两个二维数组(每个传感器一个)定义为全局变量.在我们的函数中,我们希望将我们想要使用的一个数组复制到一个工作数组并近似我们的值.
所以这是代码:
...
unsigned int ir_werte_re[][] = {
{8,553},
...
{83,133}
};
unsigned int ir_werte_li[][] = {
{8,566},
...
{83,147}
};
...
unsigned int geradenaproximation(unsigned int messwert, unsigned int seite)
{
unsigned int working_array[16][16];
unsigned int i = 0;
if (seite == 0) {
for (i = 0; i < sizeof(working_array); i++) {
working_array[i][0] = ir_werte_li[i][0];
i++;
}
}
else {
for (i = 0; i < sizeof(working_array); i++) {
working_array[i][0] = ir_werte_re[i][0];
i++;
}
}
i = 0; …Run Code Online (Sandbox Code Playgroud) 我想编写一个python脚本来将IP地址转换为主机名.我正在使用Linux机器.我没有在whois命令中看到这些信息.是否有任何命令始终提供正确的主机名(尽可能准确)?
我用这个脚本加密我的Lua代码.
local script = string.dump(
function()
local function h4x(strtbl)
buffer=""
for v in strtbl do
buffer=buffer..strtbl[v]
end
return buffer
end
print("encrypted")
end
)
buff=""
for v=1,string.len(script) do --Convert our string into a hex string.
buff=buff..'\\'..string.byte(script,v)
end
file=io.open('encrypted.txt','w') --Output our bytecode into ascii format to encrypted.txt
file:write(buff)
file:flush()
file:close()
Run Code Online (Sandbox Code Playgroud)
encrypted.txt的输出类似于"00/12/46/4/2/6/4/62 /".我如何解密字节码?
fd = open("/dev/null", O_RDWR);
if (fd == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"open(\"/dev/null\") failed");
return NGX_ERROR;
}
if (dup2(fd, STDIN_FILENO) == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDIN) failed");
return NGX_ERROR;
}
if (dup2(fd, STDOUT_FILENO) == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDOUT) failed");
return NGX_ERROR;
}
if (fd > STDERR_FILENO) {
if (close(fd) == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "close() failed");
return NGX_ERROR;
}
}
Run Code Online (Sandbox Code Playgroud)
man告诉我dup2() makes newfd be the copy of oldfd, closing newfd first if necessary.: …
我正在为我的应用程序选择数据库.我一直在使用MySQL的时间最长,但对于我目前的应用程序,性能和可伸缩性很重要,我知道MySQL有其局限性,我听过很多关于键值存储,基于列的DB和基于文档的DB等等.我调查过:
它们似乎(或声称)比MySQL之类的关系数据库更快.
我正在使用Ruby on Rails,并且有上述所有客户端因此它应该不是问题.
我的数据模型大部分都很简单,主要集中在与不同项目(如照片,视频,帖子等)相关的用户对象(具有丰富的配置文件和首选项),并且每个用户对象都有一个或多个标签.
这些数据库是新的这一事实似乎并没有为他们提供大量的在线资源.而且它们在结构上是不同的,所以稍后从一个切换到另一个并不是微不足道的.
我希望你能就我认为最适合我的应用程序的DB提供你的意见,这些数据库将具有良好的性能和规模.谢谢,
谭
我有一个指向函数的指针.我想要:
if (mode == 0)
{
const unsigned char *packet = read_serial_packet(src, &len);
} else {
const unsigned char *packet = read_network_packet(fd, &len);
}
Run Code Online (Sandbox Code Playgroud)
但我不能这样做,因为我的编译器在我稍后在代码中使用指针时会抱怨.
error: 'packet' undeclared (first use in this function)
Run Code Online (Sandbox Code Playgroud)
这很奇怪.它没有if语句,但现在我需要我的程序能够从不同的来源获取数据.这样做不可能吗?我认同.如果不是,还有其他简单的方法来获得我正在尝试的东西吗?
非常感谢.
我正在尝试解析日志文件中的各种信息,其中一些信息放在方括号内.例如:
Tue, 06 Nov 2007 10:04:11 INFO processor:receive: [someuserid], [somemessage] msgtype=[T]
Run Code Online (Sandbox Code Playgroud)
使用sed,awk或其他unix实用程序从这些行中获取'someuserid'的优雅方法是什么?