After a long time of being Mia, I went back to the wit lab and asked if I could continue research. This morning I entered the lab to find out what I should be doing next. I did come prepared btw. Sam told me I needed Ubuntu so I tried making it work on my Mac as a separate Partition. Unfortunately I wasn't successful. Despite following the online instructions it simply didn't work. My back uphold was to install it via VMware fusion.
VMware fusion installed Ubuntu without a fuss.
When I finally arrived he told me that there was a software I had to install. One of the phd students had the sOftware on a USB. He was there yet and would be there until later in the day.
I assumed that the software was a special software that you install on to Ubuntu .
As it turns out, the USB that the Phd student had was just a installation for Ubuntu .
I totally wasted my time waiting for this USB. I guess it was my fault for not asking what this software was suppose to be.
Since I already had Ubuntu I just had to download gnuradio.
If I had asked more questions and was more vocal about what I had already done, the. I could have saved time. Instead of spending the morning waiting and reading I could have spent it figuring out the gnu radio.
The phd student was named Lin . He helped me install the gnuradio via a script offered by the download website.
The installation was a partial success. It failed when trying to clone
The Git repository containing the gnu radio 3.5.3
After reading documentation of how to install manually without
The script I came to realize two things.
1)Lin downloaded the gnu radio tarball even though he didn't need to
2)the script needed adjusting
The purpose of the script was to automate downloading and installing gnuradio and various other things needed to interface with the usrp device.
Lin didnt not have to download the tarball. He could have simple placed the script in an empty folder and ran the scripts and it would have been A-O-K
When the Git failed at check out I asked Sam
for some help but he didnt quite understand the
Problem so he suggested trying an older version.
It wasn't correct but I helpped me figure out the real
Problem. In th script it clones the latest repository from
Git. The URL called by the script wasn't working.
Luckily the gnu radio website offered an alternative
Link. After changing the script to call the alternate
URL, the installation completed without a complaint.
The moral of the story is to never assume.
If you choose to assume, be vocal about what your assumption
Was. That way you would get a complete understanding .
Ps
They told me that the gnu radio didnt install when they tried Ubuntu on a virtual machine.
I think the real problem was in the script. Since Sam was familiar
With the error message he got about Git failing at check out,
I theorize that it was the same message he got long
Ago. This message was probably the same one that
Stopped them from successfully installing the gnu radio
Software on the ubuntu virtual machine.
It's only a guess though.... I could be totally wrong.
Pss
There is a way for osx to run the gnu radio. You have to use
FINK or MACPORTS. I will attempt it with my snow leopard partition.
Wednesday, April 11, 2012
Tuesday, March 6, 2012
Client server in Operating Systems
There are several methods of a client communicating with a server. But why do you need a client and a server? The applications are numerous. One example would be using ssh to log into your school's cs account. In this accound they give you space and no matter where you log in, you get the same "desktop". You have access to your account and all your programs and files. It looks and behaves as if every computer you log into becomes you local machine.
In reality, the computer you are logging into is a client and it contains none of this information. It is stupid and doesn't have a mind of its own. When you interact with the client the client will always notify the server of the changes and and ask "WHAT DO I DO?!?!" the server will answer it when ever it feels like it. When it is ready it will make changes as needed and then it will tell the client what to do.
The client "mounts" your disk on to itself. It connects to the server and accesses your disk. But to get that access it needs to mount your disk onto itself. The server has the disk stored on it somewhere.
The client has a read cache but it doesn't have a write cache. It just isn't practical to have a write cache. Instead the client must have its data written directly to the disk (which is stored in the server)
After this question a questions started to brew.
I had an Interview for an Internship some time ago and they basically gave us some code and had us implement a few things. There were two applications. A client application and a server application. The server would always be running in one terminal. In another terminal a client might be running. The server is always on and it waits for a client to talk to it.
In our assignment, the client would send the server an ASCII character. The server would recieve it and it would increment it by one. (i.e. send A recieve B)
The interface of the code was nearly identical. At the time I didn't give much thought to it. I didn't have the luxury to ponder about what I had just witnessed. But as i sit in class learning about this topic I begin to wonder how one application speaks to another application.
on the highlevel, SURE it sends a message to the server. But how?
a SOCKET
Sounds rather familiar. My TA Sean Foley told me about this. I didn't much about it except that it's used to send a string.
The pieces are comming together. The socket is the middle man that allows the server and the client to communicate.
if the client and server were on the same computer then having a single SOCKET (aka fancy message buffer) would be fine.
But lets say that you computer is the server and my computer is a the client. It wouldn't make much sense to have a single socket somewhere in the middle. You would have to pretty much connect to two computers.
So instead, your computer has a socket and my computer has a socket. The socket is allows external input.
When my computer wants to talk to your computer, my computer will send its message to your computer's socket. the socket is a buffer, so eventually the your computer will notice it and take action. It will then respond and send a message to the client's socket.
end
This reminds me quite a bit about implementing the UART is embedded systems class. Although these devices could be done syncronously, it would be more practical to have a handshake protocall and ahve then opperate asyncronously. In my design of RXD, I would take in the signal and then save it into RXD's output buffer. the RXD would then tell the TXD that it has permission to read .
However, it seems that in the socket example, the buffer would be on TXD. RXD would write to TXD's buffer and then tell TXD that it should look at its buffer.
its kind of like the mailman(RXD) stopping by and giving you mail and then telling you(TXD) to check it. Maybe I should try implementing this again using this version of design.
In reality, the computer you are logging into is a client and it contains none of this information. It is stupid and doesn't have a mind of its own. When you interact with the client the client will always notify the server of the changes and and ask "WHAT DO I DO?!?!" the server will answer it when ever it feels like it. When it is ready it will make changes as needed and then it will tell the client what to do.
The client "mounts" your disk on to itself. It connects to the server and accesses your disk. But to get that access it needs to mount your disk onto itself. The server has the disk stored on it somewhere.
The client has a read cache but it doesn't have a write cache. It just isn't practical to have a write cache. Instead the client must have its data written directly to the disk (which is stored in the server)
After this question a questions started to brew.
I had an Interview for an Internship some time ago and they basically gave us some code and had us implement a few things. There were two applications. A client application and a server application. The server would always be running in one terminal. In another terminal a client might be running. The server is always on and it waits for a client to talk to it.
In our assignment, the client would send the server an ASCII character. The server would recieve it and it would increment it by one. (i.e. send A recieve B)
The interface of the code was nearly identical. At the time I didn't give much thought to it. I didn't have the luxury to ponder about what I had just witnessed. But as i sit in class learning about this topic I begin to wonder how one application speaks to another application.
on the highlevel, SURE it sends a message to the server. But how?
a SOCKET
Sounds rather familiar. My TA Sean Foley told me about this. I didn't much about it except that it's used to send a string.
The pieces are comming together. The socket is the middle man that allows the server and the client to communicate.
if the client and server were on the same computer then having a single SOCKET (aka fancy message buffer) would be fine.
But lets say that you computer is the server and my computer is a the client. It wouldn't make much sense to have a single socket somewhere in the middle. You would have to pretty much connect to two computers.
So instead, your computer has a socket and my computer has a socket. The socket is allows external input.
When my computer wants to talk to your computer, my computer will send its message to your computer's socket. the socket is a buffer, so eventually the your computer will notice it and take action. It will then respond and send a message to the client's socket.
end
This reminds me quite a bit about implementing the UART is embedded systems class. Although these devices could be done syncronously, it would be more practical to have a handshake protocall and ahve then opperate asyncronously. In my design of RXD, I would take in the signal and then save it into RXD's output buffer. the RXD would then tell the TXD that it has permission to read .
However, it seems that in the socket example, the buffer would be on TXD. RXD would write to TXD's buffer and then tell TXD that it should look at its buffer.
its kind of like the mailman(RXD) stopping by and giving you mail and then telling you(TXD) to check it. Maybe I should try implementing this again using this version of design.
Saturday, February 11, 2012
IO Redirection and pipes in Eclipse (and xCode)
I have a program that produces two executable files. One is called "render" and the other is called "runsim".
The way that i would run the program is to open up a console/terminal and enter:
"./runsim < env0 | ./render"
render handles the graphics and runsim controls the movement of the objects. "env0" is a textile that holds that parameters of what the graphic is.
If you want this to run in eclipse there are two things that you must do
1) use your custom makefile
2) add command line arguments to the make file
*it is assumed that you are using linux
To use your own make file you must go to:
properties-->C/C++ Build --> Makefile generation
Then
you must untick "Generate Makefile automatically"
(You might have to set the build location)
Now if you want to be able to use command line arguments such as pipes and IO redirects it is helpful to simply add new stuff to the make file
Simply add
<name> : <command line arguments>
===============================
For example lets say this is my make file
===============================
all: render runsim
render: render.o
render.cpp thing.cpp thing2.cpp -o render
runsim: runsim.o
runsim.cpp it.cpp. it2.cpp -o runsim
----------------------------------------------------------
I would add "special: ./runsim < env0 | ./render"
==============================
the resulting makefile
==============================
I would add "special: ./runsim < env0 | ./render"
==============================
the resulting makefile
==============================
all: render runsim special
special:
./runsim < env0 | ./render
render: render.o
render.cpp thing.cpp thing2.cpp -o render
runsim: runsim.o
runsim.cpp it.cpp. it2.cpp -o runsim
----------------------------------------------------------
When you build using this makefile, eclipse will actually run the command line specified by special.
Now if only I could get it to work on osx. If you run the above example on osx it will actually complain about "<" saying that there is no rule to make target. I tried getting it to run on Xcode 4 but it doesn't like it. it won't even work on the console. There must be a special character that OSX like to use. If anyone knows how this is done, please share**
**UPDATE this can work in Xcode 4
(The problem i had was that Xcode was inserting spaces instead of tabs
in my makefile. makefiles require that you use tabs not spaces (marked <tabs>)
**UPDATE this can work in Xcode 4
(The problem i had was that Xcode was inserting spaces instead of tabs
in my makefile. makefiles require that you use tabs not spaces (marked <tabs>)
==============================
special = ./runsim < env0 | ./render
all: render runsim
<tabs>$(special)
render: render.o
<tabs>render.cpp thing.cpp thing2.cpp -o render
runsim: runsim.o
<tabs>runsim.cpp it.cpp. it2.cpp -o runsim
----------------------------------------------------------
Alternatively, if you don't want the command line arguments to run when you "make all"
you can modify it such that you would have to type "make special"
Alternatively, if you don't want the command line arguments to run when you "make all"
you can modify it such that you would have to type "make special"
==============================
CMD= ./runsim < env0 | ./render
all: render runsim
special:
<tabs> $(CMD)
render: render.o
<tabs>render.cpp thing.cpp thing2.cpp -o render
runsim: runsim.o
<tabs>runsim.cpp it.cpp. it2.cpp -o runsim
----------------------------------------------------------
i'm not sure how to make Xcode invoke make special. right now all it does is the default
meaning that it will run make all since "all" was the first one it saw. If somehow I could
have it run make all and then after that make special. I do not know the answer to that. If anyone out
there knows, Please share.
Saturday, January 28, 2012
using custom Makefile in Xcode 4
If you are like me, you are new to the whole IDE thing. If you are like me, you are used to using makefiles. Yes, I am talking about c++ Make files.
however, If you are like me, you want to use the power of Xcode to help you manage your code. So lets get started.
The reason I make this tutorial is because most of the stuff available is for past versions. sure, you can dig through Xcode 4 documentation, but chances are, you won't find it.
Lets give a brief introductions as to what IDE's do. Here are my favorite features.
1) Auto- complete
2) debugger
Auto-complete really helps when you hate memorizing function names. It also helps when you don't want to miss spell anything. for example what if you were working with an object but you forgot the name of the function?
Lets say we have an object "tempObj A" ; // tempObj is the type and A is the variable name
I simply have to type "A." that is "A" followed by a "." and it will give me suggestions. This is a very powerful tool and may be the reason you stick to IDE's
The debugger is very powerful. Much better then using the GDB in terminal. even though I had learned about the GDB in my intro to CS classes, I never bothered to use it. This is where IDE's make debuggers actually useful. When you run your code in debugging mode you can step through each line of code. You can even enter the function you were to call.
ok
Now to xcode.
If you are like me, then you have been using EMACS to edit all of your code. And if you are like me, then you want to use XCODE as an editor. You also want to use it so that you can "make" your program. By the end of this tutorial, you will be able to use a custom make file that will run your code.
1) Start a new project and select the empty
2) On the left you will see your project file. click it to highlight.
3) Look for the work target. Now click the button to make a new target.
4) create an external build system and follow the prompts
5) now targets should have a bulls eye looking thing under it. in the directory text box you are ring in insert the path to the directory that holds your makefile
6) now you need to add the files to your project. file-> add files to ....
now assuming you were able to make your program by typing "make" in the terminal.
you should be able to press the big play button at the lot left. It will compile your code.
But thats not all....you want it to run, right?
Well you have to edit the scheme.
once you do that, go to the run tab and change the executable to the name of your executable as per your make file. (i.e. a.out)
now when you click the big play button, you should be able to build and run the code.
Unfortunately.....you won't be able to make use of auto complete.
at least not yet =)
lucky for you I spent a very long time trying to looking at Xcode and reading documentation in order to tell you the short cut on how to do it.
if you want to enable autocomplete, you have to go under target membership. Unfortunately, the external built target doesn't like to be checked. So what you have to do is make another target but choose command line tool.
after you make it go back to "target membership" and check the box. You will have to do this for every file you select. Kind of annoying.
Just so you know, I may in the future add pictures to this blog. But only if you readers are having difficulty understanding my explanations in text.
however, If you are like me, you want to use the power of Xcode to help you manage your code. So lets get started.
The reason I make this tutorial is because most of the stuff available is for past versions. sure, you can dig through Xcode 4 documentation, but chances are, you won't find it.
Lets give a brief introductions as to what IDE's do. Here are my favorite features.
1) Auto- complete
2) debugger
Auto-complete really helps when you hate memorizing function names. It also helps when you don't want to miss spell anything. for example what if you were working with an object but you forgot the name of the function?
Lets say we have an object "tempObj A" ; // tempObj is the type and A is the variable name
I simply have to type "A." that is "A" followed by a "." and it will give me suggestions. This is a very powerful tool and may be the reason you stick to IDE's
The debugger is very powerful. Much better then using the GDB in terminal. even though I had learned about the GDB in my intro to CS classes, I never bothered to use it. This is where IDE's make debuggers actually useful. When you run your code in debugging mode you can step through each line of code. You can even enter the function you were to call.
ok
Now to xcode.
If you are like me, then you have been using EMACS to edit all of your code. And if you are like me, then you want to use XCODE as an editor. You also want to use it so that you can "make" your program. By the end of this tutorial, you will be able to use a custom make file that will run your code.
1) Start a new project and select the empty
2) On the left you will see your project file. click it to highlight.
3) Look for the work target. Now click the button to make a new target.
4) create an external build system and follow the prompts
5) now targets should have a bulls eye looking thing under it. in the directory text box you are ring in insert the path to the directory that holds your makefile
6) now you need to add the files to your project. file-> add files to ....
now assuming you were able to make your program by typing "make" in the terminal.
you should be able to press the big play button at the lot left. It will compile your code.
But thats not all....you want it to run, right?
Well you have to edit the scheme.
once you do that, go to the run tab and change the executable to the name of your executable as per your make file. (i.e. a.out)
now when you click the big play button, you should be able to build and run the code.
Unfortunately.....you won't be able to make use of auto complete.
at least not yet =)
lucky for you I spent a very long time trying to looking at Xcode and reading documentation in order to tell you the short cut on how to do it.
if you want to enable autocomplete, you have to go under target membership. Unfortunately, the external built target doesn't like to be checked. So what you have to do is make another target but choose command line tool.
after you make it go back to "target membership" and check the box. You will have to do this for every file you select. Kind of annoying.
Just so you know, I may in the future add pictures to this blog. But only if you readers are having difficulty understanding my explanations in text.
Wednesday, September 14, 2011
Test of strength Problem
Problem:
Create a system to play the Test of Strength Game often seen on carnival midways. Inputs A indicate a sensor reading on how hard of an impact the contestant hit the target with the hammer. A non-Zero input A indicates a valid hit. When the valid bit is asserted, read the ‘impact’ sensor and then output a sequence on the B output that starts with B0 and “rises” to the Nth output bit, then “falls” back to zero.
In order to manipulate B to make it easy, we do a little bit of bit manipulation. We know that left shifting increases the value by a power of two. We however need a sequence of 1's. If we want a four continuous 1's then we need to left shift a 1 four times and then subtract one from it.
--------
1<< 4 gives us 0x10
and subtracting it by 1 gives us 0x0F
I continue this pattern and produce the following.
Now it's time for the state machines.
I use a program called RIBs in order to create the state machines. It is a great program that generates C code for you based on the state machine you create with it. (When creating this blog it was version 2.4.1)
I used two state machines to accomplish this. The first state machine deals only with the sensor. It runs with a period of 200ms in order to capture the hit's without missing any. The second state machine deals with the lights. It transitions from state to state every 1000ms.
In the table above I use a formula that looks like this "--(1 << 5)" how ever, the compiler that the program uses does not accept it so I had to break it into two parts. I would have to save (1 << 5) into the variable and then subtract 1 from that variable.
As mentioned before, this program generate's C code. Below is the C code that it generates based off my state machine:
/*
This code was automatically generated using the Riverside-Irvine State machine Builder tool
Version 2.4 --- 9/14/2011 21:7:5 PST
*/
#include "rims.h"
/*This code will be accessible from all State Machines.*/
unsigned char score =0;
unsigned char medium = 0;
unsigned char i = 0;
unsigned char flag = 0;
void TimerISR() {
flag = 1;
}
const unsigned long int numTasks = 2;
const unsigned long int SM1_period = 200;
const unsigned long int SM2_period = 1000;
const unsigned long int GCD = 200;
typedef struct task {
int state;
unsigned long int period;
unsigned long int elapsedTime;
int (*TickFct)(int);
} task;
enum SM1_States { SM1_WAIT, SM1_HIT } SM1_State;
int SM1_Tick(int state) {
/*VARIABLES MUST BE DECLARED STATIC*/
/*e.g., static int x = 0;*/
/*Define User Variables and Functions For this State Machine Here.*/
switch(state) { // Transitions
case -1:
state = SM1_State = SM1_WAIT;
break;
case SM1_WAIT:
if (A) {
state = SM1_State = SM1_HIT;
score = A;
}
else if (!A) {
state = SM1_State = SM1_WAIT;
}
break;
case SM1_HIT:
if (!score) {
state = SM1_State = SM1_WAIT;
}
else if (score) {
state = SM1_State = SM1_HIT;
}
break;
default:
state = -1;
} // Transitions
switch(state) { // State actions
case SM1_WAIT:
break;
case SM1_HIT:
break;
default: // ADD default behaviour below
break;
} // State actions
return state;
}
enum SM2_States { SM2_s0, SM2_s1, SM2_s2 } SM2_State;
int SM2_Tick(int state) {
/*VARIABLES MUST BE DECLARED STATIC*/
/*e.g., static int x = 0;*/
/*Define user variables for this state machine here.*/
switch(state) { // Transitions
case -1:
state = SM2_State = SM2_s0;
break;
case SM2_s0:
if (!score) {
state = SM2_State = SM2_s0;
}
else if (score) {
state = SM2_State = SM2_s2;
}
break;
case SM2_s1:
if (( i <1)) {
state = SM2_State = SM2_s0;
score = 0;
medium = 0;
}
else if (!(i < 1)) {
state = SM2_State = SM2_s1;
medium = (1 << (--i));
--medium;
}
break;
case SM2_s2:
if (!(i <= score)) {
state = SM2_State = SM2_s1;
}
else if ((i <= score)) {
state = SM2_State = SM2_s2;
medium =(1<<(++i));
--medium;
}
break;
default:
state = -1;
} // Transitions
switch(state) { // State actions
case SM2_s0:
B = medium;
i = 0;
break;
case SM2_s1:
B = medium;
break;
case SM2_s2:
B = medium;
break;
default: // ADD default behaviour below
break;
} // State actions
return state;
}
int main() {
unsigned long int i; //scheduler for-loop iterator
task tasks[2];
tasks[0].state = -1;
tasks[0].period = 200;
tasks[0].elapsedTime = 200;
tasks[0].TickFct = &SM1_Tick;
tasks[1].state = -1;
tasks[1].period = 1000;
tasks[1].elapsedTime = 1000;
tasks[1].TickFct = &SM2_Tick;
TimerSet(GCD);
TimerOn();
while(1) {
for ( i = 0; i < numTasks; ++i ) {
if ( tasks[i].elapsedTime == tasks[i].period ) {
tasks[i].state = tasks[i].TickFct(tasks[i].state);
tasks[i].elapsedTime = 0;
}
tasks[i].elapsedTime += GCD;
}
while(!flag);
flag = 0;
}
return 0;
}
Subscribe to:
Posts (Atom)


