This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
blog:fall2015:tmosgrov:journal [2015/09/29 19:57] – [09/28/2015] tmosgrov | blog:fall2015:tmosgrov:journal [2015/12/02 21:02] (current) – [12/02/2015] tmosgrov | ||
---|---|---|---|
Line 214: | Line 214: | ||
For instance, when trying to span multiple arguments for a single command. I wanted(if possible) to use a loop mid command that would iterate more arguments, but I'm starting to think this is not possible. Instead, I formatted a string that whiptail would take using quotes and spaces when appropriate. It worked, but I'm having trouble discarding certain characters without things breaking. So, now I have a moderately ugly output on the whiptail menu under the book title' | For instance, when trying to span multiple arguments for a single command. I wanted(if possible) to use a loop mid command that would iterate more arguments, but I'm starting to think this is not possible. Instead, I formatted a string that whiptail would take using quotes and spaces when appropriate. It worked, but I'm having trouble discarding certain characters without things breaking. So, now I have a moderately ugly output on the whiptail menu under the book title' | ||
+ | |||
+ | When returning whiptails argument from STDERR to a variable. I found it easy enough to save to a file(even though I would have killed to get it straight to the variable instead), and then I would cat the file for it's value. After the value had been recorded I would remove the file as if nothing ever happened... But, I still wish there was a nicer way to do this. :) | ||
As a by-product of these headaches. I have already started to rethink of things. Like, how the user can view the catalog and its data that exists on a flat-file! If a user is aloud/able to scroll through said data. Why not present the file to them as is? Save the work of inputing/ | As a by-product of these headaches. I have already started to rethink of things. Like, how the user can view the catalog and its data that exists on a flat-file! If a user is aloud/able to scroll through said data. Why not present the file to them as is? Save the work of inputing/ | ||
Line 220: | Line 222: | ||
More to come! | More to come! | ||
+ | |||
+ | ====09/ | ||
+ | |||
+ | This will be a quick update due to running short on time because I have been glued to the library project, and am enjoying every bit of it. | ||
+ | |||
+ | So, I happily made a revision that was a tribute to my previous post stressing how important revisions are. I think things are starting to look like an envisioned output. At least an output I'm happy with to convey my understanding, | ||
+ | |||
+ | I ran into a few walls here and there, but I made a lot of progress. I now have a presentable user interface with tasteful windows that work (looping back to where they should and not locking user's in which happened me today :p). The main function I'm taking my sweet time with (non-intentional) is the Get A Book feature. Where a user will enter a correct book ID, if the book has not been checked out by another user, and the ID is valid. The user is successfully advanced to a confirmation screen that reminds them to return the book by the end of the semester. The username, and time/date of the checkout is recorded in the same row as the book in the flat-file catalogue. Otherwise, If the book has been checked out you are advanced to a screen that informs you who has the book along with what time/date it was checked out. | ||
+ | |||
+ | I decided it would work smoothly if the ID book field was a four digit hexadecimal value. Therefore this would leave room for roughly a nice 65,000 books, but also be a convenient small number to memorize. The user could search the catalogue maybe greping for a books name. Then all the user needs to do is snag the four digit book ID and punch it into the Get A Book screen. | ||
+ | |||
+ | Sorry this was a frantic and poor entry, but it was a rushed one. | ||
+ | I will follow up with more soon. | ||
+ | |||
+ | ====10/ | ||
+ | |||
+ | Ok, I just wanted to follow up with the god awful opus entry above ^. | ||
+ | I was a bit excited, and pressed for time. | ||
+ | |||
+ | Back to the details of the library project. | ||
+ | The current output I have completed is a sturdy menu system. | ||
+ | The main menu features two options [Get A Book][EXIT]. | ||
+ | |||
+ | Get A Book | ||
+ | * Allows the user to checkout a book | ||
+ | * The user inputs a 4 digit hex number aka the book ID. | ||
+ | * If the book ID is invalid the user will be looped back to the ID entry menu, or if they escape. | ||
+ | * After the user inputs a valid book ID the script prompts the user with the book of the ID entered. | ||
+ | * The prompt is there to double check with the user that this is indeed the book they want. | ||
+ | * After the book is confirmed by the user. The script inserts username, time, and date the book was checked out. | ||
+ | * The catalog is then updated with this information. Preventing others from checking out the same book. | ||
+ | |||
+ | Exit | ||
+ | * An obvious escape from the main menu. Which can also be done by pressing ESC. | ||
+ | |||
+ | A list of ideas that I don't want to forget. | ||
+ | * Add an " | ||
+ | * Add a return menu for returning books that creates another document(or the same) of books being returned. | ||
+ | * Create admin menus like updating returned books to ensure they were in fact returned. | ||
+ | * This enables me to assign certain users as " | ||
+ | * Add a Add Book menu for librarians to streamlines book entry. | ||
+ | * For the add menu the Input field for ID would decrement from FFFF by each book entry. | ||
+ | |||
+ | <code bash> | ||
+ | 1# | ||
+ | 2 menu=1 | ||
+ | 3 while [ " | ||
+ | 4 do | ||
+ | 5 | ||
+ | 6 | ||
+ | 7 then | ||
+ | 8 | ||
+ | 9 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | 66 done | ||
+ | 67 clear | ||
+ | 68 exit 0 | ||
+ | </ | ||
+ | |||
+ | Some things I learned. | ||
+ | |||
+ | I should probably get around to learning awk. For everything I have wanted to do with the catalog file when it came to modifying field/ | ||
+ | |||
+ | True false return from whiptail that counts for the ok and cancel buttons. Helps for making menus user friendly. | ||
+ | Done with an if( ) sub shell conditional. As a pose to conditional comparison if [ ] statement. | ||
+ | Which again reminds me of my love for bash even more. Promoting this "do it your way", " | ||
+ | |||
+ | I should probably dedicate some time to datacomm next! :'D | ||
+ | |||
+ | ====10/ | ||
+ | |||
+ | So, things are slowing down as we approach Columbus day break. | ||
+ | I have been working steadily on my library project while neglecting other work... *caugh* *caugh* sde0 | ||
+ | Sorry, but I believe I will be able to make good use of this time, and grind out some sde0, and do some HPC like activities along the way. | ||
+ | |||
+ | I was eager to play with virtual box recently. I did a reinstall of debian, and set up a host-only network so I could ssh to the Debian box using putty. I was happy because after having done last semesters HPC activities I found setting up and finding things a breeze. Not only that, but I now am starting to feel at home on a unix/linux system. | ||
+ | |||
+ | I will brainstorm some offhand HPC ideas that could possibly be tackled over the break. | ||
+ | * Deploy, configure, and play with squid on vbox. | ||
+ | * Do other various networking set ups with vms | ||
+ | * Continue library shell script | ||
+ | * Work on sde0 both gd and docuwiki' | ||
+ | |||
+ | ====10/ | ||
+ | |||
+ | Break is over now... Nothing was done... Nothing at all. | ||
+ | It is time to re engage, and get some work done. | ||
+ | Where I left off was with a finished demo of lairbrary. I say demo because it gets the job done, but it completely ignores the possibility of others using lairbrary while modifying the catalog file at the same time. I also worry that the output file of the whiptail command could over write another user's option file while in use. Which may not be a problem because the file is extremely temporary. I think naming the option file according to the $USER name could be a quick solution to prevent two instances of the program from deleting the option file. That is assuming these files always output to in the same location of the scripts contents as a pose to the users current working directory. Which I could be completely wrong, and sending it to their home or working directory could be another solution. I'm going to make a massive revisions of this regarding these issues. Not only that, but I would like to simplify redundant commands, standardize window sizes, fix the way text appears in menus, and better the catalog' | ||
+ | |||
+ | So, I know I have been promising, and promising to work on sde0. Through guilt I will dedicate more time to the project. I decided I would use the output of the C program that displays all packets specs and time, and parse that information with a handy dandy bash script! The script will output a bar graph in charter' | ||
+ | |||
+ | I'm very pumped to see Mr. Stallman too! | ||
+ | |||
+ | ====10/ | ||
+ | |||
+ | Quick entry! | ||
+ | |||
+ | Busting my butt on the lair-brary! | ||
+ | Matt gave me a hand with coming up with a solution for handling concurrent file writes. Where a dragon will yell at you other wise. ;P The script looks for a .lock file which means another users is modifying the library' | ||
+ | |||
+ | My initial idea for handling concurrent file modifications was to create some sort of tokenized effort. What I called "last one out" meaning the last user to exit having modified the catalog would consolidate and update the pending updates, but this proved to complicated. I'm starting to learn that programming is about simplification short and sweet. If you over abstract your going to have a hell of a time wrapping your head around it. However, if this is an issue chances are there' | ||
+ | |||
+ | Finally, I thoroughly enjoyed the Richard Stallman talk. It was nice to go to an event with like minded people, and feel apart of a community. | ||
+ | |||
+ | ====10/ | ||
+ | |||
+ | Another quick entry regarding recent finding and ambitions. | ||
+ | Over the weekend I unintentionally worked on many hpc related things. Funny how that happens. | ||
+ | Wound if installing my first third-party library that was offered out side of the standard application packages that are available. A pidgin plugin for facebook chat which had me scratching my head for a while until I found a repository of one of the developers. Facebook had recently moved away from using xamp, and moved to something google based. Go figure. Also, I again played a lot with virtual box (probably more than I should have), but I got the guest additions installed, virtual mounted some directories, | ||
+ | |||
+ | I jumped back on the lair-braryv2 for a bit today I decided to go to fixed window sizes because I did not like the way proportioning the screen with the terminal size work, but I did try it! | ||
+ | Finally, I have been staring at .ogg vorbis wishing I knew more about codecs, audio decoding, and audio decoding. Hopefully, I'll get around to playing with some audio libraries. Just maybe! | ||
+ | |||
+ | See ya! | ||
+ | |||
+ | ====11/ | ||
+ | Wow, today was highly productive in regards to HPC. I came in with a question, and came out with an answer plus code to show! Today was a good day. So, while working on the lair-brary I was struggling finding a way where I could numerically sort the library' | ||
+ | Consider the following input! | ||
+ | |||
+ | <code console> | ||
+ | FFFF BOOK TITLE | ||
+ | AUTHOR NAME | ||
+ | USERNAME DATE etc. | ||
+ | |||
+ | FFFE BOOK TITLE | ||
+ | AUTHOR NAME | ||
+ | USERNAME DATE etc. | ||
+ | </ | ||
+ | |||
+ | Supplemented with... | ||
+ | |||
+ | <code bash> | ||
+ | sed '/ | ||
+ | N | ||
+ | s/\n/[-]/g | ||
+ | N | ||
+ | s/\n/[-]/g | ||
+ | N | ||
+ | s/\n/[-]/g | ||
+ | }' input | ||
+ | </ | ||
+ | |||
+ | Output looks like... | ||
+ | |||
+ | <code console> | ||
+ | FFFF BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc.[-] | ||
+ | FFFE BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc. | ||
+ | </ | ||
+ | |||
+ | Sort! | ||
+ | |||
+ | <code console> | ||
+ | FFFE BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc.[-] | ||
+ | FFFF BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc. | ||
+ | </ | ||
+ | |||
+ | Finally, revert back! | ||
+ | |||
+ | <code bash> | ||
+ | sed ' | ||
+ | </ | ||
+ | |||
+ | Final Output should look like this (note. techinally this example would not work due to the missing newline character on the last entry) | ||
+ | |||
+ | <code console> | ||
+ | FFFE BOOK TITLE | ||
+ | AUTHOR NAME | ||
+ | USERNAME DATE etc. | ||
+ | |||
+ | FFFF BOOK TITLE | ||
+ | AUTHOR NAME | ||
+ | USERNAME DATE etc. | ||
+ | </ | ||
+ | |||
+ | More to come! | ||
+ | |||
+ | ====11/ | ||
+ | |||
+ | So, the weekend was productive. In fact, it was the most productive weekend I have witnessed so far this semester. Tackled tic-tac-toe, | ||
+ | |||
+ | Things keep getting better, and better! | ||
+ | |||
+ | ====11/ | ||
+ | |||
+ | It has been some time since my last submit. However, this time I bring good news. | ||
+ | After mingling around on the internet, and obsessing over a potential new found hobby. Somebody dropped the line usb programming which immediately struck my fancy. What better of a project for datacomm and HPC? What really solidified this was " | ||
+ | |||
+ | This will be where I will record all my resources and information. I hope it will be more interesting than some of my previous posts. | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | ====11/ | ||
+ | |||
+ | USB/ | ||
+ | MAX devices 127 | ||
+ | USB devices uses a 7bit address | ||
+ | |||
+ | "All communications on the bus are intiated by the host" | ||
+ | There is no communication usb-device to usb-device. | ||
+ | |||
+ | "A device cannot initiate data transfering, | ||
+ | the host." The only exception being a ' | ||
+ | |||
+ | USB On-The-Go, An interesting extension on the USB spec. | ||
+ | |||
+ | Cables specially designed to only connect host-to-device IE. not host-to-host, | ||
+ | device-to-device. | ||
+ | |||
+ | 4 Wire shielded cable two of which are a twisted pair (D+, D-). The fourth wire (VBUS) | ||
+ | provides 5V supply of power. | ||
+ | |||
+ | Additional Resources | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | Using libusbhid | ||
+ | Ran into libfcntl while reading somones source that reads input from a joystick. | ||
+ | libfcntl or (file control) provides a means to accessing a file that is already open. | ||
+ | Generally after a usb device is plugged in it is already being accessed by the host. | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | "A USB HID report descriptor is one of the descriptors that a USB host can request from a USB device. HID devices send data to the host using reports, and the descriptor tells the host how to interpret the data." | ||
+ | |||
+ | / | ||
+ | |||
+ | ====12/ | ||
+ | |||
+ | Back to USB. I've been looking in all the wrong places. The library I should have been focusing on was libusb which references all of the other libraries I have occasionally stared far too long at. Those of which were probably being referenced as a lower level layer by libusb.h. | ||
+ | |||
+ | Regarding libusb, | ||
+ | When interfacing with usb devices you have two choices Synchronous, | ||
+ | |||
+ | note: Asynchronous offers simultaneous I/O operations or threading. Which libusb supports with its thread-control. | ||
+ | |||
+ | **USB Transfer Types** | ||
+ | * Control Transfers | ||
+ | * Interrupt Transfers | ||
+ | * Isochronous Transfers | ||
+ | * Bulk Transfers | ||
+ | |||
+ | **Control Transfers**- Command or status operations. | ||
+ | |||
+ | |||
+ | **Interrupt Transfers**- Initiated by the device to request some action from the host. | ||
+ | |||
+ | |||
+ | **Isochronous Transfers**- Transfers which are used to carry data the delivery of which is crucial. | ||
+ | |||
+ | |||
+ | **Bulk Transfers**- Transfers which are used to carry data the delivery of which is not crucial. | ||
+ | |||
+ | |||
+ | "All transfers take the form as packets, which contain certain control information and error checking fields." | ||
+ | |||
+ | **The typical libusb procedure** | ||
+ | - Get device list | ||
+ | - Clear device list with libusb_free_device_list) | ||
+ | - Claim usb interface with libusb_claim_interface | ||
+ | - Do the desired I/O operations | ||
+ | - Release the device by using libusb_release_interface | ||
+ | - Close the device libusb_close | ||
+ | - Exit session libusb_exit |