F.J Kong's Blog

BRAVO HOTEL ONE SIERRA CHARLIE WHISKEY

linux

linux 串口接收不到0x11的解决方法

这两天在树莓派上写了个串口通讯的程序,测试发现总是少一位数据,前后查了很久程序,没毛病啊 我勒个擦 原来发现是这个问题  转载一下,原文链接在这里 http://blog.chinaunix.net/uid-27717694-id-3492291.html 网上许多流行的linux串口编程的版本中都没对c_iflag(termios成员变量)这个变量进行有效的设置,这样传送ASCII码时没什么问题,但传送二进制数据时遇到0x0d,0x11和0x13却会被丢掉。不用说也知道,这几个肯定是特殊字符,被用作特殊控制了。关掉ICRNL和IXON选项即可解决。 c_iflag &= ~(ICRNL | IXON); 0x0d 回车符CR 0x11 ^Q VSTART字符 0x13 ^S VSTOP字符 ICRNL 将输入的CR转换为NL IXON 使起动/停止输出控制流起作用 在《UNIX环境高级编程第二版》第18章第11小节看到把终端I/O设置为原始模式(串口通讯就是终端I/O的原始模式)时输入属性设置为 term.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); 屏蔽了许多属性,怪不得有人说如果是使用串口通讯c_iflag和c_oflag都设置为0就行了! 以下是我的设置的一些重要的串口属性 term.c_cflag |= CLOCAL | CREAD; term.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); term.c_oflag &= ~OPOST; term.c_iflag […]

memory buffer as FILE*

http://stackoverflow.com/questions/539537/memory-buffer-as-file #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { FILE *f = fopen(“/dev/null”, “w”); int i; int written = 0; char *buf = malloc(100000); setbuffer(f, buf, 100000); for (i = 0; i < 1000; i++) { written += fprintf(f, “Number %d\n”, i); } for (i = 0; i < written; i++) { printf(“%c”, […]

多个串口节点名称不固定的解决方法 How to identify multiple USB-serial adapters under Ubuntu

copy from here:http://stackoverflow.com/questions/4800099/how-to-identify-multiple-usb-serial-adapters-under-ubuntu-10-1 The USB “KERNEL” was not enough in my case, but I found the port number. I am aware that what I’m proposing now might be considered an insane hack, but it works for me.. for now.. I would actually be pleased to see a more elegant suggestion that accomplish something similar.. So… […]

Pinyin Search for Unity Dash

用ubuntu的用户可能Dash用的没那么频繁, 但是不得不说一些Scope做的真的是实用性非常不错,例如在Dash里面搜索文件是一个很有用的功能。但是有一个问题是搜英文的文件或者目录还好,如果搜索的是含有中文的文件名的话,用户体验就低很多。 首先你要打开Dash,鼠标点一下搜索栏(不点的话切不出来输入法),快捷键切出输入法,依次输入你要搜索的中文,然后得到你要找的文件。是不是很麻烦? 如果可以不用切出输入法直接敲拼音可以完成以上等效的功能是不是会很酷?然后花了点时间尝试,发现其实不是很难的一件事情 下面这个小的demo首先演示了打开输入法搜索 紧接着演示了一下用拼音搜索 这个项目包含两部分: 用于Dash里面搜索的scope插件 源码在这里   https://github.com/kroody/unity-scope-pinyinsearch 用于转换中文到拼音的程序源码在这里  https://github.com/kroody/chinese2pinyin

How to install linux with ISO under grub

grub> loopback loop (hd0,6)/raring-desktop-i386.iso grub> set root=(loop) grub> linux /casper/vmlinuz boot=casper iso-scan/filename=/raring-desktop-i386.iso grub> initrd /casper/initrd.lz grub> boot

My config of rtorrent

min_peers = 90 max_peers = 500 max_uploads = 500 min_peers_seed = 10 max_peers_seed = 500 download_rate = 0 upload_rate = 0 directory = /mnt/pt/down session = /mnt/pt/session #port_range = 6890-6999 port_range = 6890-6899 port_random = yes check_hash = no encoding_list = UTF-8 dht = disable peer_exchange = no trackers.enable=yes use_udp_trackers = yes

How to add a screen session to rc.local

I use rtorrent as my PT client. so I want to run rtorrent when I startup os. cd /mnt/pt/down && /usr/bin/screen -s /bin/bash -dmS rtorrent ~/run.sh

How to fix GNOME Terminal cursor in awesome?

copy from http://unix.stackexchange.com/questions/63949/how-to-fix-gnome-terminal-cursor-in-awesome I’m using awesome 3.4.11 on Ubuntu 13.04, and my default terminal is GNOME Terminal 3.6.1. After starting several terminals, it seems the cursor behavior gets disconnected from window focus in some of them: Doesn’t blink when the window has focus Blinks even when the window doesn’t have focus   bug report at here […]

VIRTUALBOX HIGH CPU USAGE PROBLEM SOLVED [Copy from others] virtualbox 虚拟机 xp cpu 占用 100%

终于解决了。。。。。事实告诉我们学好英语很重要哦 http://tech.shantanugoel.com/2009/07/07/virtualbox-high-cpu-usage-problem-solved.html A few days ago, I had to install Windows XP as a guest OS on my Ubuntu Hardy machine as I needed to carry out some Visual Studio work. What I noticed was that my CPU usage went through the roof (constantly at 100%) even if the guest was completely idle. Result: My […]

How to quickly post image to IRC

http://img.vim-cn.com/ elimage(1) ELIMAGE elimage(1) NAME Elimage: CLI Image Pastebin SYNOPSIS curl -F 'name=@/path/to/image' http://img.vim-cn.com/ or upload via your browser: DESCRIPTION Paste image files with command line. You can give <span style="text-decoration: underline;">-F</span> more times to paste more images. EXAMPLES $ curl -F 'name=@screenshot.png' http://img.vim-cn.com/ <a href="http://img.vim-cn.com/97/2d8490849c8fab885218b478cc715ab0f3f4a9">http://img.vim-cn.com/97/2d8490849c8fab885218b478cc715ab0f3f4a9</a> URLS <a href="http://p.vim-cn.com/">http://p.vim-cn.com/</a> A CLI code pastebin <a href="https://github.com/Vim-cn/elimage">https://github.com/Vim-cn/elimage</a> […]

Previous Posts