This semesor I take OS course under the instruction of Professor Geoffery. He is a really funny and nice guy. Because of him, I watched super bowl for the first time(no laugh pls...). And I found that it is reallllllly interesting!!!
I am glad to take this course althogh it would be very tough. But that's why I come here.
Hope I can be stronger two months later.
I am Liang Hong. A student in CSE department of UB. This blog is mainly used as a record of my study.
2012年2月5日星期日
git
do not use Ctrl+z but Ctrl+x to exit when enter git commit help window
if you face this error:
if you face this error:
fatal: Unable to create '/path/to/repo/.git/index.lock': File exists.
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.build
this can solve the problem
rm .git/index.lock
----------------
git status
git diff
git reset HEAD <>
git checkout -- <>
git add <>
git commit
------------------
git tag -a "asst0-start" -m "ASST0 start"
vim ./gitignore
.depend
/defs.mk
kern/compile/
user/testbin/randcall/calls.c-----------------------When you clone a repository, Git automatically sets up the
remote repository you cloned from as linked to your clone.Before you perform any merge it is best to have any changes in your
git remote -v
working directory committed.
2012年2月4日星期六
gdb tips
#gdbinit
(gdb) target remote unix:.sockets/gdb
#when gdb initiate, it will search and execute a file named .gdbinit under current directory
#if you are in gdb debugiing, use
source /.gdbinit
-----------------------------
r
n
s
c
b ; info b; d b n; disable b n; enable n
watch
bt
f n
l
i locals
set
p i
finish
c
q
-------------------------
(gdb) p i
$21 = 101
(gdb) p/a i
$22 = 0x65
(gdb) p/c i
$23 = 101 'e'
(gdb) p/f i
$24 = 1.41531145e-43
(gdb) p/x i
$25 = 0x65
(gdb) p/t i
$26 = 1100101
(gdb) target remote unix:.sockets/gdb
#when gdb initiate, it will search and execute a file named .gdbinit under current directory
#if you are in gdb debugiing, use
source /.gdbinit
-----------------------------
r
n
s
c
b ; info b; d b n; disable b n; enable n
watch
bt
f n
l
i locals
set
p i
finish
c
q
-------------------------
(gdb) p i
$21 = 101
(gdb) p/a i
$22 = 0x65
(gdb) p/c i
$23 = 101 'e'
(gdb) p/f i
$24 = 1.41531145e-43
(gdb) p/x i
$25 = 0x65
(gdb) p/t i
$26 = 1100101
2012年1月29日星期日
VirtualBox
when install the deb package of virtualbox, u might face this error:
Unpacking replacement virtualbox-4.1 ...
dpkg: dependency problems prevent configuration of virtualbox-4.1:
virtualbox-4.1 depends on libcurl3 (>= 7.16.2-1); however:
Package libcurl3 is not installed.
dpkg: error processing virtualbox-4.1 (--install):
dependency problems - leaving unconfigured
so the problem is about the dependance package libcurl3 was not successfully installed in your ubuntu.
solution:
sudo apt-get -f install
-f Attempt to correct a system with broken dependencies in place
After this operation, 553 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main libcurl3 i386 7.21.3-1ubuntu1.5 [220 kB]
Fetched 220 kB in 1s (121 kB/s)
Selecting previously deselected package libcurl3.
(Reading database ... 196705 files and directories currently installed.)
Unpacking libcurl3 (from .../libcurl3_7.21.3-1ubuntu1.5_i386.deb) ...
Setting up libcurl3 (7.21.3-1ubuntu1.5) ...
Setting up virtualbox-4.1 (4.1.8-75467~Ubuntu~natty) ...
Adding group `vboxusers' (GID 123) ...
Done.
* Stopping VirtualBox kernel modules [ OK ]
* Uninstalling old VirtualBox DKMS kernel modules [ OK ]
* Trying to register the VirtualBox kernel modules using DKMS [ OK ]
* Starting VirtualBox kernel modules [ OK ]
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Processing triggers for python-central ...
-----------------------------------------------------------------------
#see version of ubuntu
cat /etc/issue
sudo lsb_release -a
-----------------------------------------------------
#fix apt-get upgrade error
Unpacking replacement virtualbox-4.1 ...
dpkg: dependency problems prevent configuration of virtualbox-4.1:
virtualbox-4.1 depends on libcurl3 (>= 7.16.2-1); however:
Package libcurl3 is not installed.
dpkg: error processing virtualbox-4.1 (--install):
dependency problems - leaving unconfigured
so the problem is about the dependance package libcurl3 was not successfully installed in your ubuntu.
solution:
sudo apt-get -f install
-f Attempt to correct a system with broken dependencies in place
After this operation, 553 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main libcurl3 i386 7.21.3-1ubuntu1.5 [220 kB]
Fetched 220 kB in 1s (121 kB/s)
Selecting previously deselected package libcurl3.
(Reading database ... 196705 files and directories currently installed.)
Unpacking libcurl3 (from .../libcurl3_7.21.3-1ubuntu1.5_i386.deb) ...
Setting up libcurl3 (7.21.3-1ubuntu1.5) ...
Setting up virtualbox-4.1 (4.1.8-75467~Ubuntu~natty) ...
Adding group `vboxusers' (GID 123) ...
Done.
* Stopping VirtualBox kernel modules [ OK ]
* Uninstalling old VirtualBox DKMS kernel modules [ OK ]
* Trying to register the VirtualBox kernel modules using DKMS [ OK ]
* Starting VirtualBox kernel modules [ OK ]
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Processing triggers for python-central ...
-----------------------------------------------------------------------
#see version of ubuntu
cat /etc/issue
sudo lsb_release -a
-----------------------------------------------------
#fix apt-get upgrade error
sudo rm /var/lib/apt/lists/* -vf
--------------------------------------------------------
uname -a
uname -r
--------------------------------------------------------
uname -a
uname -r
2012年1月26日星期四
vim: easy way to look code
gdb InsertionSort
Ctrl+x a / layout src
--------------------------------------------
/etc/vim/vimrc
set nu
set hlsearch
-------------------------------
grep -r 512 ~/src
grep -r -E -n -B1 -A1 "runnable|threads" ~/src/kern
-i skip the diff between a and A
-I skip .o
-w DEBUG_KMEMLEAK but not DEBUG_KMEMLEAK_EARLY_LOG_SIZE
-e "-lianghong"
find ~/gnuradio -name ben*
Ctrl+x a / layout src
--------------------------------------------
/etc/vim/vimrc
set nu
set hlsearch
-------------------------------
grep -r 512 ~/src
grep -r -E -n -B1 -A1 "runnable|threads" ~/src/kern
-i skip the diff between a and A
-I skip .o
-w DEBUG_KMEMLEAK but not DEBUG_KMEMLEAK_EARLY_LOG_SIZE
-e "-lianghong"
find ~/gnuradio -name ben*
2012年1月24日星期二
vim: two file copy&paste diff
eg:
vim execlp.c
:sp/:vsp
:e fork1.c
Ctrl+w w
v
yy
Ctrl+w w
p
----------------------------
:vert diffsplit ~/src/kern/vm/kmalloc.c
:diffthis
vim -d file1 file2/vimdiff file1 file2
vim execlp.c
:sp/:vsp
:e fork1.c
Ctrl+w w
v
yy
Ctrl+w w
p
----------------------------
:vert diffsplit ~/src/kern/vm/kmalloc.c
:diffthis
vim -d file1 file2/vimdiff file1 file2
2012年1月18日星期三
gnuradio code for USRP2 TX/RX
#pkt.py(define send_pkt function, send the payload, according to eof to tell whether to send more packets or not)
#packet_utils.py(make packet, build a packet, given access code, payload, and whitener offset)
#packet will have access code at the beginning, followed by length, payload and finally CRC32
self.connect(self._pkt_input, self._modulator, self)
self.connect(self, self._demodulator, self.correlator, self.framer_sink)
-----------------------------------------------------------------------------
dbpsk.py
"differential BPSK modulation and demodulation"
"input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband"
#function bits_per_symbol will return 1, so arity is 2
arity = powe(2, self.bits_per_symbol())
self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity])
--------------------------------------------
psk.py
# identity mapping, range(2) is start from 0(default), the end is 2, so it means [0, 1, 2]
binary_to_ungray = {
2 : range(2),
4 : range(4),
8 : range(8)
}
-----------------------------------------
//how the actual symbol mapping to constellations is done
gr_map_bb.cc
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
gr_map_bb_sptr
gr_make_map_bb (const std::vector &map)
{
return gnuradio::get_initial_sptr(new gr_map_bb (map));
}
gr_map_bb::gr_map_bb (const std::vector &map)
: gr_sync_block ("map_bb",
gr_make_io_signature (1, 1, sizeof (unsigned char)),
gr_make_io_signature (1, 1, sizeof (unsigned char)))
{
for (int i = 0; i < 0x100; i++)
d_map[i] = i;
unsigned int size = std::min((size_t) 0x100, map.size());
for (unsigned int i = 0; i < size; i++)
d_map[i] = map[i];
}
int
gr_map_bb::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
for (int i = 0; i < noutput_items; i++)
out[i] = d_map[in[i]];
return noutput_items;
}
-------------------------------------------
dbpsk.py
#symbol clock recovery
self.receiver=gr.mpsk_receiver_cc(arity, 0,
self._costas_alpha, self._costas_beta,
fmin, fmax,
self._mm_mu, self._mm_gain_mu,
self._mm_omega, self._mm_gain_omega,
self._mm_omega_relative_limit)
-----------------------------------
//Basically M-PSK modulations in GNU Radio utilize the function
gr_mpsk_receiver_cc.cc
------------------------------------------------------
use gr.file_sink() to dump all kinds of data in GNU Radio
The dumped data can be read from Matlab using some conversion codes
---------------------------------------------------------
you need to make and make install when debugging, otherwise you don't add your new modifications to the library and install the library for the python code to access.
eg:
change gr_mpsk_receiver_cc.cc in gnuradio-core/src/lib/general/
change pkt.py in gnuradio-core/src/python/gnuradio/blks2impl
---------------------------------------------------------
benchmark_tx.py
benchmark_rx.py
usrp_transmit_path.py
usrp_receive_path.py
transmit_path.py
receive_path.py
pkt.py
packet_utils.py
dbpsk.py
dqpsk.py
gr_map_bb.cc
-------------------------------
tmr
1 trace dbpsk.py for connection with pkt.py
2 try code below
#!/usr/bin/env python
from gnuradio import gr, eng_notation, gru, window, blks2
from gnuradio import audio
from gnuradio import usrp
from gnuradio.eng_option import eng_option
from optparse import OptionParser
from gnuradio import gr_unittest
class my_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
self.data = (1+2j, 3+4j, 5+6j)
self.src = gr.vector_source_c (self.data)
self.converte = gr.complex_to_float()
self.re_sink = gr.vector_sink_f ()
self.im_sink = gr.vector_sink_f ()
self.connect (self.src, (self.converte,0))
self.connect ((self.converte,0), self.re_sink)
self.connect((self.converte,1), self.im_sink)
if __name__ == '__main__' :
tb = my_top_block()
try:
tb.run()
except KeyboardInterrupt:
pass
print "src data: ", tb.data
print "real: ", tb.re_sink.data()
print "imag: ", tb.im_sink.data()
3 use --log of benchmark to see what .dat file can get
4 Q: if I have made one DQPSK transmission for image transfer and now I want to check the transmission and reception of the image at different SNR values. I am unable to find any signal block where i can change the SNR value .
A:
#packet_utils.py(make packet, build a packet, given access code, payload, and whitener offset)
#packet will have access code at the beginning, followed by length, payload and finally CRC32
self.connect(self._pkt_input, self._modulator, self)
self.connect(self, self._demodulator, self.correlator, self.framer_sink)
-----------------------------------------------------------------------------
dbpsk.py
"differential BPSK modulation and demodulation"
"input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband"
#function bits_per_symbol will return 1, so arity is 2
arity = powe(2, self.bits_per_symbol())
self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity])
--------------------------------------------
psk.py
# identity mapping, range(2) is start from 0(default), the end is 2, so it means [0, 1, 2]
binary_to_ungray = {
2 : range(2),
4 : range(4),
8 : range(8)
}
-----------------------------------------
//how the actual symbol mapping to constellations is done
gr_map_bb.cc
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
gr_map_bb_sptr
gr_make_map_bb (const std::vector &map)
{
return gnuradio::get_initial_sptr(new gr_map_bb (map));
}
gr_map_bb::gr_map_bb (const std::vector &map)
: gr_sync_block ("map_bb",
gr_make_io_signature (1, 1, sizeof (unsigned char)),
gr_make_io_signature (1, 1, sizeof (unsigned char)))
{
for (int i = 0; i < 0x100; i++)
d_map[i] = i;
unsigned int size = std::min((size_t) 0x100, map.size());
for (unsigned int i = 0; i < size; i++)
d_map[i] = map[i];
}
int
gr_map_bb::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
for (int i = 0; i < noutput_items; i++)
out[i] = d_map[in[i]];
return noutput_items;
}
-------------------------------------------
dbpsk.py
#symbol clock recovery
self.receiver=gr.mpsk_receiver_cc(arity, 0,
self._costas_alpha, self._costas_beta,
fmin, fmax,
self._mm_mu, self._mm_gain_mu,
self._mm_omega, self._mm_gain_omega,
self._mm_omega_relative_limit)
-----------------------------------
//Basically M-PSK modulations in GNU Radio utilize the function
gr_mpsk_receiver_cc.cc
------------------------------------------------------
use gr.file_sink() to dump all kinds of data in GNU Radio
The dumped data can be read from Matlab using some conversion codes
---------------------------------------------------------
you need to make and make install when debugging, otherwise you don't add your new modifications to the library and install the library for the python code to access.
eg:
change gr_mpsk_receiver_cc.cc in gnuradio-core/src/lib/general/
change pkt.py in gnuradio-core/src/python/gnuradio/blks2impl
---------------------------------------------------------
benchmark_tx.py
benchmark_rx.py
usrp_transmit_path.py
usrp_receive_path.py
transmit_path.py
receive_path.py
pkt.py
packet_utils.py
dbpsk.py
dqpsk.py
gr_map_bb.cc
-------------------------------
tmr
1 trace dbpsk.py for connection with pkt.py
2 try code below
#!/usr/bin/env python
from gnuradio import gr, eng_notation, gru, window, blks2
from gnuradio import audio
from gnuradio import usrp
from gnuradio.eng_option import eng_option
from optparse import OptionParser
from gnuradio import gr_unittest
class my_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
self.data = (1+2j, 3+4j, 5+6j)
self.src = gr.vector_source_c (self.data)
self.converte = gr.complex_to_float()
self.re_sink = gr.vector_sink_f ()
self.im_sink = gr.vector_sink_f ()
self.connect (self.src, (self.converte,0))
self.connect ((self.converte,0), self.re_sink)
self.connect((self.converte,1), self.im_sink)
if __name__ == '__main__' :
tb = my_top_block()
try:
tb.run()
except KeyboardInterrupt:
pass
print "src data: ", tb.data
print "real: ", tb.re_sink.data()
print "imag: ", tb.im_sink.data()
3 use --log of benchmark to see what .dat file can get
4 Q: if I have made one DQPSK transmission for image transfer and now I want to check the transmission and reception of the image at different SNR values. I am unable to find any signal block where i can change the SNR value .
A:
You will want to add a Gaussian noise source and a add block to add------------------------------------------------------------------
AWGN, or you can use the channel_model block. To set the SNR, you will
first have to calculate the signal power in your simulation and from
their, determine the noise power for your desired SNR. The convert the
noise power to an amplitude, which is what the noise source block
takes. Look in gnuradio-examples/python/digital/benchmark_loopback.py
to see an example of these calculations.
discussion is from here
订阅:
博文 (Atom)