# Picocom instead of Screen

I’m using screen to read the text from a serial console. The problem is the output seems to only have newline \n but not carriage return \r, so the display looks like this…

Line1
Line2
Line3


I wonder if there is any patch to fix this issue?

When I need to read the serial data from some devices in Linux, I used the screen but I’ve found the similar problem above. And it was frustrating that there is almost no solution to solve the problem. So I start to try Picocom, a tiny and easy-use tool like screen. The most importance is that it can map something to avoid the above phenomenon.

you can type command as follows:

picocom -b115200 /dev/ttyUSB0 –imap lfcrlf

where -b represents the baud rate and /dev/ttyUSB0 is the name of device. imap is the input map which means map [LF] to [CRLF]  in input data.

Refer to this for more detail.

# make or Sudo make?

Since I has not installed the Chinese input in my ubuntu, what I can do is to record that in English.

Problem: I compiled my Contiki codes (for example, “hello-world”) and upload to the telosB. Generally, we use the instructions as follows:

But the failed words instead of expected results appeared on the terminal. It said about permission denied for the ttyUSBx ports.

I searched on Google and found most circumstances like me are with higher version of msp430-gcc. If you added sudo the aforementioned command, you well get “make: msp430-gcc: Command not found” something like that. It looks confused and I posted my solution here which is referred to this.

Solution:

sudo adduser $USER dialout Type the above command to add “user” to the dialout group and log out for this change to take effect next time you start or restart the computer directly. Everything will be ok! # Latex中如何插入matlab的eps图片 用matlab生产一张figure后，用以下命令行可以实现将当前figure保存为eps文件 print log_f_vs_k.eps -depsc2 -r600 在latex中用以下语句插入： \begin{figure}[!h] %\vspace{-0.2cm} \centering {\epsfig{file = matlab/log_f_vs_k.eps, width = 12cm, angle=-90}} \caption{speed of convergence} \label{fig speedofconvergence} \end{figure} 其中，angle参数用来调节图片输出的方位，有时候print输出的eps图片会有90度翻转。当然该语句需要 \usepackage{epsfig} 用上述方式输出的eps有一个好处，就是规避了用save as直接输出可能会出现的坐标轴消失的bug。 # stash & stash pop 当你正在写一段代码的时候，突然有其他事请需要打断你编码的过程，此时使用git的正确姿势应该是： git stash 把当前未提交的改动“复制”到另一个地方暂存起来，使用git status命令可以发现 On branch master nothing to commit, working directory clean 待要恢复的时候执行： git stash pop # 关于.gitignore 当我们使用vim的时候总会有临时文件产生，例如.swp或者~。在以前粗放型的git使用中(使用git add –all命令)，会把这些临时文件或者编译所产生的中间变量都加入到stage中。其实这种并不是一个好的(起码是精致的)git使用习惯。恰当的做法是使用.gitignore文件。 .gitignore文件有自己的格式： • 所有空行或者以注释符号 ＃ 开头的行都会被 Git 忽略。 • 可以使用标准的 glob 模式匹配。 • 匹配模式最后跟反斜杠(/)说明要忽略的是目录。 • 要忽略指定模式以外的文件或目录，可以在模式前加上惊叹号(!)取反。 所谓的 glob 模式是指 shell 所使用的简化了的正则表达式。星号(*)匹配零个或多个任意字符；[abc]匹配任何一个列在方括号中的字符(这个例子要么匹配一个 a，要么匹配一个 b，要么匹配一个 c)；问号(?)只匹配一个任意字符；如果在方括号中使用短划线分隔两个字符，表示所有在这两个字符范围内的都可以匹配(比如[0-9]示匹配所有0到9的数字)。 一个.gitignore例子： #此为注释-将被git忽略 #忽略所有.a结尾的文件 *.a #但lib.a除外 !lib.a #仅仅忽略项目根目录下的TODO文件，不包括subdir/TODO /TODO #忽略build/目录下的所有文件 build/ #会忽略doc/notes.txt，但不包括doc/server/arch.txt doc/*.txt #ignore all .txt files in the doc/ directory doc/**/*.txt 两个星号连在一起在路径中有特殊的含义： 1. **/foo表示的是任意路径下的foo文件或路径；**/foo/bar表示的是任意路径下在foo里面的bar文件或路径。 2. abc/**表示的是abc下的所有文件，具有无限深度。 3. a/**/b表示a/b，a/x/b或者a/x/y/b等等。 4. 除上述三种情形之外的连续星号视为非法。 另外，gitignore.io可以帮你自动生成常规的.gitignore文件。 # git config –global, system or local? 一般情况下，git配置过程中第一步就是配置用户名和邮箱： git config –global user.name “sean MA” git config –global user.mail “ma.xiaoyuan.mail@gmail.com” 但以前一直没有深究为什么要用global参数。 [以下引用自git-scm] git 使用一系列的配置文件来存储你定义的偏好，它首先会查找/etc/gitconfig文件，该文件含有对系统上所有用户及他们所拥有的仓库都生效的配置值，如果传递system参数给git config命令，git会读写这个文件。 接下来git会查找每个用户的~/.gitconfig文件，你能传递global项让git读写该文件。 最后git会查找由用户定义的各个库中git目录下的配置文件(.git/config)，该文件中的值只对属主库有效。 以上阐述的三层配置从一般到特殊层层推进，如果定义的值有冲突，以后面层中定义的为准，例如：在.git/config与/etc/gitconfig的较量中，.git/config得了胜利。当然你也可以直接手动编辑这些配置文件。 # 在Ubuntu14.04下安装MSP430-gcc 第一步：解压缩文件msp430-toolchain-linux-i386-2.1.tar.bz2，并将其放到/opt目录下。 tar jxvf msp430-toolchain-linux-i386-2.1.tar.bz2 sudo mv msp430-toolchain-linux-i386-2.1 /opt/msp430-toolchain/msp430-toolchain-linux-i386-2.1 第二步：修改环境变量 在~/.bashrc中的最后加上以下语句： export PATH=/opt/msp430-toolchain/msp430-toolchain-linux-i386-2.1/bin:/opt/msp430-toolchain/msp430-toolchain-linux-i386-2.1/lib:/opt/msp430-toolchain/msp430-toolchain-linux-i386-2.1/include:$PATH

source ~/.bashrc

sudo vim /etc/ld.so.conf.d/msp430-toolchain.conf

/opt/msp430-toolchain/msp430-toolchain-linux-i386-2.1/lib
/opt/msp430-toolchain/msp430-toolchain-linux-i386-2.1/libexec

sudo ldconfig

msp430-gcc -v

gcc version 4.7.0 20120302 (mspgcc internal 20120716) (GCC)msp430-gcc 4.7.0(32位版本)压缩包下载地址：

http://pan.baidu.com/s/1o6vkWDc

# 如何用PyInstaller将.py程序转换为.exe

1、下载PyInstaller 2、运行一下命令 python pyinstaller.py –onefile –icon=app.ico “app.py” –onefile：建立一个单独的可执行文件。 –icon：为.exe文件添加一个图标文件。 参考：http://pythonhosted.org/PyInstaller/

# python库在windows下的安装

python setup.py install

MARK一下。

# Linux文件类型与文件目录

Linux文件类型： 普通文件、目录文件、连接文件和特殊文件，可用file命令来识别。

– 普通文件：如文本文件、C语言元代码、SHELL脚本、二进制的可执行文件等，可用cat、less、more、vi、emacs来察看内容，用mv来改名。

– 目录文件：包括文件名、子目录名及其指针。它是LINUX储存文件名的唯一地方，可用ls列出目录文件。

– 连接文件：是指向同一索引节点的那些目录条目。用ls来查看是，连接文件的标志用l开头，而文件面后以”->”指向所连接的文件。

– 特殊文件：LINUX的一些设备如磁盘、终端、打印机等都在文件系统中表示出来，则一类文件就是特殊文件，常放在/dev目录内。例如，软驱A称为/dev/fd0。

Linux文件目录：

/

This is the root directory. The mothership. The home field. The one and only top directory for your whole computer. Everything, and I mean EVERYTHING starts here. When you type ‘/home’ what you’re really saying is “start at / and then go to the home directory.”

/root

This is where the root user lives. The root user is the god of your system. Root can do anything, up to and including removing your entire filesystem. So be careful using root.

/boot

Linux的内核及引导系统程序所需要的文件目录，比如 vmlinuz initrd.img 文件都位于这个目录中。在一般情况下，GRUB或LILO系统引导管理器也位于这个目录。

/bin

Here’s where your standard linux utilities(read programs) live — things like “ls” and “vi” and “more”. Generally this directory is included in your path. What this means is that if you type ‘ls’, /bin is one of the places your shell will look to see if ‘ls’ means anything.

/sbin

/etc

Here’s where the administrative and system configuration stuff lives. For instance, if you have samba installed, and you want to modify the samba configuration files, you’d find them in /etc/samba.

/dev

Here’s where files that control peripherals live. Talking to a printer? Your computer is doing it from here. Same goes for disk drives, usb devices, and other such stuff.

/home

Here’s where your data is stored. Config files specific to users, your Desktop folder(whick makes your desktop what it is), and any data related to your user. Each user will have their own /home/username folder, with the exception of the root user.

/tmp

This is the Temporary folder. Think of it as a scratch directory for your Linux system. Files that won’t be needed by programs once their used once or twice are put here. Many Linux systems are set to automatically wipe the /tmp folder at certain intervals, so don’t put things you want to keep here.

/usr

Here’s where you’ll find extra utilities that don’t fit under /bin or /etc. Things like games, printer utilities, and whatnot. /usr is divided into sections like /usr/bin for programs, /usr/share for shared data like sound files or icons, /usr/lib for libraries whick cannot be directly run but are essential for running other programs.Your package manager takes care of the things in /usr for you.

/opt

Here’s where optional stuff is put. Trying out the latest Firefox beta? Install it to /opt where you can delete it without affecting other settings. Programs in here usually live inside a single folder whick contains all of their data, libraries, etc.

tips: 在Linux中，/opt目录是存放某些大型软件或者某些特殊软件的目录，比如谷歌浏览器 (Google Chrome)默认就是安装在/opt中。但是我们一般不会把opt单独分在一个区，因为/opt中大多数时候是空的，即使安装了软件也不会太多，而且有些软件的容量还比较大，这样就会占用/的容量，我们可以在其它你愿意的地方建立一个目录来将/opt“转移”到别处，比如/usr是单独分在一个 区，容量有50G，而且/usr本来就是安装软件的地方，所以可以在/usr下建立一个叫opt的文件夹，然后右键点击这个/usr下的opt，选择“创建链接”，得到一个名为“到opt的链接”文件，然后把这个文件剪切到/下，将原来的/opt删除，再将“到opt的链接”改名为opt就可以了，以后我们安装在/opt的软件实际上是安装到了/usr/opt下(实际上是一个符号链接)。

/proc

/usr/local

This is where most manually installed(ie. outside of your package manager) software goes. It has the same structure as /usr. It is a good idea to leave /usr to your package manager and put any custom scripts and things into /usr/local, since nothing important normally lives in /usr/local.

/lost found

/mnt

http://baike.baidu.com/view/1634.htm?wtp=tt