User Tools

Site Tools


blog:fall2015:tmosgrov:journal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
blog:fall2015:tmosgrov:journal [2015/10/26 19:58] – [10/21/2015] tmosgrovblog:fall2015:tmosgrov:journal [2015/12/02 21:02] (current) – [12/02/2015] tmosgrov
Line 391: Line 391:
  
 See ya! See ya!
 +
 +====11/04/2015====
 +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's catalog. The issue being that each entry resides on 3 lines delimited by a newline character. The problem I ran into was trying to manipulate multiple lines of data in said way. So, I began to ask around which finally came down to the ultimatum... I have to learn how to use more advanced features with sed. I learned my first sed script today custome polished to be very own needs. :)
 +Consider the following input!
 +
 +<code console>
 +FFFF BOOK TITLE
 +AUTHOR NAME
 +USERNAME DATE etc.
 +
 +FFFE BOOK TITLE
 +AUTHOR NAME
 +USERNAME DATE etc.
 +</code>
 +
 +Supplemented with...
 +
 +<code bash>
 +sed '/^[[:xdigit:]]* .*$/{                                             
 +N
 +s/\n/[-]/g
 +N
 +s/\n/[-]/g
 +N
 +s/\n/[-]/g
 +}' input
 +</code>
 +
 +Output looks like...
 +
 +<code console>
 +FFFF BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc.[-]
 +FFFE BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc.
 +</code>
 +
 +Sort!
 +
 +<code console>
 +FFFE BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc.[-]
 +FFFF BOOK TITLE[-]AUTHOR NAME[-]USERNAME DATE etc.
 +</code>
 +
 +Finally, revert back!
 +
 +<code bash>
 +sed 's/\[-\]/\n/g' input
 +</code>
 +
 +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.
 +</code>
 +
 +More to come!
 +
 +====11/09/2015====
 +
 +So, the weekend was productive. In fact, it was the most productive weekend I have witnessed so far this semester. Tackled tic-tac-toe, and became best buddies with ncurses. I found the library to be extremely robust, but extremely accessible. Once I got the curses moving around the way I wanted the rest was history. I got sick of the lair-brary worrying about multiple user issues which led me straight to tic-tac-toe a single no more than two user experience... Maybe, I should make an undefeat-able  AI?!
 +
 +Things keep getting better, and better!
 +
 +====11/16/2015====
 +
 +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 "ioctl" a unix tool for interfacing with usb devices.
 +
 +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://en.wikibooks.org/wiki/Serial_Programming/USB|Serial Programming USB]]
 +
 +[[http://linux.die.net/lkmpg/x892.html|Talking to Device Files]]
 +
 +[[http://www.usbmadesimple.co.uk/|USB Made Simple]]
 +
 +====11/18/2015====
 +
 +USB/Bluetooth Notes:
 +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, but must wait to be asked to transfer data by
 +the host." The only exception being a 'suspend' that results in a remote wakeup.
 +
 +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, or
 +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://forums.freebsd.org/threads/usbhid-accessing-multiple-joysticks-in-one-report.53155/|USBHID Sample Source]]
 +
 +[[http://www.gsp.com/cgi-bin/man.cgi?topic=hid_get_report_desc#3|More USBHID Documentation]]
 +
 +Using libusbhid  & libfcntl.
 +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://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/|Report Descriptors]]
 +
 +"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."
 +
 +/usr/share/misc/usb_hid_usages Shows ideal report descriptor formats for various usb devices.
 +
 +====12/02/2015====
 +
 +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, and Asynchronous. Synchronous offers a less involved method for interfacing with a USB device to make a transfer. Offering a "one function call" solution to make a transfer, but those calls may "sleep" inside libusb_bulk_transfer() until a transfer has completed. This could be a pain if a transfer process is taking longer than expected to complete. While Asynchronous offers a more controlled route with the ability to cancel a transfer, but is more complicated to use.
 +
 +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
blog/fall2015/tmosgrov/journal.1445889500.txt.gz · Last modified: 2015/10/26 19:58 by tmosgrov