So I did manage to program my input device from last week after Thanksgiving which was awesome. So I figured I would try to replicate Neil's python code first to interface between that device and my computer.
To do that, I realized I had a lot to do. Neil had introduced about 70 different programming languages during the lecture, and I had no idea where to start. Luckily, I had a good friend coming for Thanksgiving who gave me a run through some python coding he was doing for another project. Going over his project line by line really helped me get my bearings.
I spend some time learning python, and a lot of time installing it too. My biggest problem was that so far I've always needed to go to the one linux computer in the Arch workshop to do everything because nothing ever seems to work on my own laptop. I decided to try and save time, I would install ubuntu on my computer. I spent too many hours failing to make my laptop a dual boot machine. Gave up. Then spent a couple more hours figuring out how to run Ubuntu on a virtual machine. Most people in the class have already done this... I probably should've done this earlier. But anyway, importantly, if you're trying to run Ubuntu on VMware and it's not working. I highly suggest that you visit your BIOS when you turn on your computer and check that your computer's VT-x is enabled (see right). That's what worked for my Yoga 2 Pro, but my searches also revealed that different computers have different BIOS options that need to be changed from VMware to work.
(Also a quick note about the Atmel programmer. If you find that it's not working and spitting the message: "did not find any USB device" then you need to make some changes to the udev .rules for the programmer. This took me FOREVER to figure out and unfortunately I didn't save the link that explain how to do this. )
With Linux finally running, I needed to plug in the board. Again, trying to save time, I decided to invest in an FTDI cord so I don't need to go to the workshop everytime I need to test something out. A trip to Microcenter however revealed FTDI cables are not very common products, even at such a well-stocked store!
So, there's an FTDI cable somewhere in the mail I ordered from Amazon for $20. It's a lot for a cable, but when I consider the amount of time I'll save having my own cable... it's worth it.
While I'm waiting, I went to the workshop and waited my turn to use the FTDI cable. I plugged it in, launched Linux, typed in Neil's python program, and nothing happened. Now, nobody ever explained to me how linux terminals really work this whole time and I've kind of just figured out how to use line commands by googling and watching over TA's shoulders. The key is you always need to know "where" you are by changing directories (cd [directory]) and to begin to know what differnt commands do ("ls" is useful for listing stuff in the directory, TAB will help complete filenames you're writing,). Anyway, the problem in this case I needed to write "python [filename] [serial port name]". I wasn't writing the actualy serial port name!
Finding the name should be easy right? Wrong.
To make your computer talk to something that's plugged into it you need to tell it where to look. For that you need the right port name. Let's take a step out to learn a little bit about the various ways to look at your USB ports in Linux. I never knew it was so complicated...
First there's "lsusb" which lists out what's plugged in but not the actual port name (which is like the address) for the device. That was frustrating to think I had the name but not getting any effect.
Then there's also "find /dev/bus/" which gives you something that looks like the locations but this isn't it either. (See the second photo)
Finally, I would suggest "dwang8@ubuntu:~$ ls /dev/ tty*". This spits out a lot of random stuff, but if you do this once without the device plugged it. Then plug the device in and run it again. You'll find there is something new there. That's the port address of the device... I hope this saves someone the hours of digging. (And many thanks to my classmate, Maya, for pointing me in this direction)
So, after navigating to where your python program is you can type "python [file] [portname]". In this case my port name was "dwang8@ubuntu:~$ sudo python hello.HC-SR04.py /dev/ttyUSB0". (Don't forget "sudo" which tells your computer to do what you tell it)
There is nothing like the feeling of finally getting something to work. That being said, I still haven't totally completed this assignment. Now I need to begin to make my own Python program to talk to the board. I had to give up my spot with the FTDI cable, but I will be trying to write some more small changes to existing code and use that as a way to figure out how this all works.