chebe: (Default)
2020-06-23 09:48 pm

Generate -5V to 5V signal from Arduino

An Arduino microcontroller can generate a square wave on PWM pins to simulate an analog wave. But the wave alternates between 5V and 0V, it doesn't change polarity.

If you have a component that expects an AC signal you need to change the 0V to 5V signal to a -5V to 5V signal.

One simple way to do this is with a SparkFun Transceiver Breakout. Connect the Power pin to either 3.3V or 5V on the Arduino, GND to GND, T2IN to a PWM pin, and T2OUT to your component. analogWrite() your required frequency to control your component.



Back of SparkFun Transceiver Breakout with labelled pins visible
Photo by [personal profile] chebe

chebe: (Default)
2017-12-14 09:22 pm

Raspberry Pi console access over USB via Serial

I picked up the Adafruit PiUART for console access over USB (incredibly useful when something is wrong with networking and you don't have a monitor handy).

1. Log into Pi and run sudo raspi-config: Interfacing options > Serial > Would you like a login shell to be accessible over serial? > Yes, Finish and reboot.
2. Connect to laptop. Turn on.
3. In Windows open Device Manager, find COM port number.
4. Open Putty, stay on main Session page, but select Serial radio button under Connection Type. Put in your COM port number under Serial line, and 115200 under Speed. Click Open.
5. A terminal window pops up, but is blank, and does nothing. Still attached, turn off Pi, and turn back on again. The window will be displaying the usual boot up info you'd see if a monitor was attached.

Apparently "That's because there's a serial console defined in the /boot/cmdline.txt".

But at least it's working.
chebe: (AsciiC)
2012-09-12 06:34 pm

Getting a hostname cloak on freenode irc

Let's try a post without pictures for now. How to get an unaffiliated cloak on freenode:

Step 1; register a nickname [as detailed here]
Step 2; join #freenode and wait patiently for a staffer to show up
Step 3; ask politely for a cloak [as here]
Step 4; once cloak is applied, thank your staffer, and check your info

Simple, and awesome. Going to test it from work tomorrow to see how well it works.

*edit* Using the webchat.freenode.net clients still set the realname to something based on your ip, but using a client that sets realname to something silly like 'purple' (hi pidgin), is a pretty good combination.
chebe: (AsciiC)
2011-05-06 01:11 pm

Checksum

Want to compute checksum/digests of your downloads? On Fedora, easy peasy;

openssl dgst -$protocol $file

$protocol examples; sha1, md5. Check man page for more.

You can then check the digest against the one supplied on the website and/or throw it into a search engine and see what comes up.
chebe: (AsciiC)
2011-02-28 06:59 pm

There are other OSs you know

We have many different kinds of Operating Systems, each with its own pluses and minuses. I think this is a very good, and important, thing. It means you have the scope to find the one that suits you just right, to enable a kind of symbiosis between you and your machine. I remember the days when you had to use Windows. I, everyday, encounter people who tell me I have to use Mac. Multiple times a day I come across people who tell me why their *nix flavour is the best. It drives me nuts. In my personal sphere the worst offenders are the Debian and Ubuntu users. I've no problem with people talking about their OS, engaging in open discussion is healthy and enlightening. It's when that conversation happens to the exclusion of all other OSs that I get annoyed. And not simply because I'm a Fedora user.

Increasingly in college we're having Ubuntu forced upon us. It makes sense, there are people in my course unfamiliar with linux, and it is widely believed to be the easiest to get into. But, they say X works with linux, when they mean Ubuntu. They give instructions only for Ubuntu. Documentation is only written for Ubuntu. There is a massive dependency on "do this and it just works". Only, when you're on another flavour, and trying to figure out why it doesn't, there are no pointers, and the instructors can offer no help. It kinda defeats the purpose don't you think? To replace one ubiquitous system with another, with equally limited knowledge of how it actually works.

Okay, my little rant is over. Here's some things you might find helpful, if you're a Fedora user.
  • When you yum install python you mightn't get everything you need. I was told to get python-usb, what I needed was yum install pyusb.

  • If you're doing a forensics course and you're being told to grab things like vinetto and reglookup you'll notice they aren't in your repos. You need the CERT repo. Save the PGP key, and add it: rpm --import forensics.asc. Download the repo rpm for your version of Fedora, and install it: rpm -ivh cert-forensics-tools-release-13.rpm. (I realise I do this in a kooky way, and there are probably better ways, but I'm set in mine :) Now, updatedb to sync before you use yum. You can install everything: yum install CERT-Forensics-Tools, or just what you're looking for, e.g. yum install reglookup.

  • gvimdiff. I had vim installed, I'm pretty sure I had diff installed. But I couldn't get gvimdiff (or vimdiff) to work. It magically sorted itself out when I realised the g => yum install vim-X11.


  • There, now we can all get back to enjoying the diversity.
    chebe: (Default)
    2011-02-13 11:37 pm

    Virtualbox

    I've had problems with VMWare, so I have decided to give VirtualBox a go. Points to note;

  • Virtualbox rpms in Fedora (13) repo don't work. Download direct from VirtualBox.
  • You create the machine first, and then when you start it for the first time you will be asked to point it to an .iso to install the OS. Have any product keys ready.
  • To use shared folders you need to install Guest Additions. It's already bundled, just not installed. Follow tutorial here.
  • Wireless. You have to enable it when your VM is shut off. Follow these steps.
  • chebe: (South Park)
    2011-02-10 03:24 pm

    OS on a Stick

    Ever get that oddly uncomfortable feeling whenever you sit down to use a computer that's not yours? Even if it's the same OS, everything is just in the wrong place, all your shortcuts missing, it's distressing.

    Ever wanted to simply bring your Desktop around with you, no matter where you are?

    First thing you might try, especially if you're a Linux user, is persistent Live USB. Like a Live CD, only on a USB stick, and you can save files to it.

  • Put the Live CD into the CD-drive. Reboot your machine, and at the BIOS make sure the CD-drive has priority in the boot list.
  • If you're using the Ubuntu 10.10 Live CD it will ask you to either try it, or install it. Try it.
  • Plug in the USB key (2.6GB+), and wait until it automagically appears on the Desktop.
  • Go to the menu: System > Administration > Startup Disk Creator
  • The iso and USB key should be auto-populated, but check to make sure.
  • The slider is how much persistent storage you want. For me it went up to 4GB (for an 8GB stick).
  • Press the 'Make Startup Disk' button. Wait.
  • When done you will have a bootable Live USB disk with persistent storage.

    (Don't want to burn a CD? You can download the iso, and use the in-built Live CD creator tools, most distros have them. Or use UNetbootin (Windows version too).)

    Great? Well, not really. Every single time you boot in it asks you to Try It or Install It. That takes extra time, it gets annoying. What I really want is a portable computer drive, an OS on a stick!

    So I can just choose Install It and point it at the USB key? Nope. It will pick up your hard-drive and try to include those existing partitions. Which will either mess up your existing MBR/grub/lilo/etc, or mean the key will only boot in that machine. Some people say to disable the hard-drive in BIOS, then try it. My older laptop doesn't have a BIOS option to disable the hard-drive, and when I tried it on my EEE it also disabled its ability to detect my USB flash key (a type of hard-drive). So, I was left with one alternative. (Okay, so there are others, but this is the simplest.)

  • Remove the hard-drive.
  • Boot into Live CD (iso no good here as the hard-drive is gone).
  • For Ubuntu: Choose Try It. Then plug in USB key, when it automagically appears, start the Install, either from the Desktop icon or the menu.
  • For BackTrack: Choose Live CD from the boot menu. Type 'startx' for a graphical interface if so inclined. Plug in the USB key. Run install.sh on the Desktop.
  • Make sure it picks up your USB key, and only your USB key. Continue installation as usual.


    There. Done and dusted. You will probably have to change the BIOS boot order on most machines you plug it into, but as long as it isn't password protected that's okay. Go, enjoy the comforts of home, wherever you are!
  • chebe: (Default)
    2010-10-08 11:58 am

    Bash string variable mangling

    Problem:
    In a very long script I have to construct several paths for use. Problem is the paths are getting mangled. Most easily seen with echo.
    For example:
    var = /opt/big_program
    new_var = ${var}/sub_folder
    echo "Look at what happens: ${new_var}"


    Output:
    /sub_foldert happens: /opt/big_program

    Solution:
    The end of the first variable must contain a 'return line' character, and is resetting the cursor before it continues, overwriting what's already there. Chances are this file (or one it reads the paths from) was created on Windows, which uses a different character to signal the end of a line.

    To fix, run:
    sed -i 's/\r//' $file_name

    Props, and endless thanks to the poster of the solution here: http://ubuntuforums.org/showthread.php?t=1239902
    chebe: (WalkSign)
    2010-07-13 01:55 pm

    Identifying your nickname on irc with Pidgin

    Okay, so you've registered your nickname with freenode, but everytime you log in through Pidgin it asks you to identify.

    Instead of typing /msg nickserv identify your_password every single time, add NickServ as a buddy, and set up a buddy pounce.

    - Right-click buddy, select 'Add Buddy Pounce'
    - Select Pounce when ... Signs on.
    - Select Action ... Send a message.
    - Type 'identify your_password' in the text box.
    - Select Options ... Recurring.
    - Then press Add to save and exit the dialog.

    Now when you sign in Pidgin will identify for you. Much better.
    chebe: (Default)
    2010-06-27 09:07 pm

    Editing Fedora Gnome menus

    Need to install a program called 'alacarte'. Then right-click the menu.

    Is there a command line way to do this? Doesn't look like it.
    chebe: (Default)
    2010-06-25 01:00 pm

    More Adventures with USB keys under Linux

    Previously:
    - Manually mounting
    - Manually setting permissions to read/write

    Today, creating live-USB discs, and manual reformatting.

    It began like this. The screen on my laptop broke. Big stripe from top to bottom, width of the hinge, all gone white. But that was okay, I took out the five year insurance, so off it went for repair. This left me with just my EEE netbook. It had a nicely functioning Fedora 11, but it's coming to the end of it's life now. I didn't want to upgrade to 12 before as I felt they were trying too many new things all at once. And I'm apprehensive of the new bootloader. But now with 13 they've had time to get it all working nicely. Time to take the leap.

    I looked up the options. Upgrading seemed attractive. preupgrade looks fairly shiney, but my /boot partition was too small at the previously recommended 200MB, and my router is in a really awkward place to enable me to sit plugged into it for a while. So, other options, upgrade from media, install from live media. I didn't have any blank CDs or DVDs handy (I've an external DVD-drive so that's not a problem for my EEE), so I thought I'd try out the Live CD on USB thing. But the live CDs don't upgrade, only install. And sure, they've changed the recommended partitions, /boot is now 500MB, and /home gets its own. Okay, why not, let's give it a go.

    Well, the good news is the images came down quickly. The rest is a bit of a saga.

    A bit of a ramble )

    In summary, I don't know why I had these problems when others don't seem to. Every program I used was Fedora based. The only thing I can think of is that the USB drive was NTFS before I reformatted it for the first time. Or that the instructions are incomplete. But, what I learned is how to manually use mkfs and that (by default at least) it doesn't assign a label. Also, I'll think I'll stick to DVDs in the future.
    chebe: (Default)
    2010-04-28 05:30 pm

    Things I Needed to Know

    How to set up individual users with sudoer rights on Red Hat/Fedora/Suse flavours.

    Assuming you have the sudo package installed. As root:

    echo 'user_name ALL=(ALL) ALL' >> /etc/sudoers
    chmod 440 /etc/sudoers


    That's it. Repeat for each user you wish to make all-powerful.
    chebe: (Default)
    2010-03-23 10:02 am

    Things I Needed To Know

    Problem: Linux uses up your 'extra' RAM for cache. But often refuses to free it when it's needed.

    Solution: sync; echo 3 > /proc/sys/vm/drop_caches

    Props: http://www.scottklarr.com/topic/134/linux-how-to-clear-the-cache-from-memory/

    *edit*
    http://www.linuxatemyram.com/
    http://www.linuxatemyram.com/play.html
    https://help.ubuntu.com/community/SwapFaq (to set swappiness)
    chebe: (Default)
    2010-03-15 11:02 am

    Things I Needed To Know (Fixing old mistake)

    I'm referring to this entry: http://chebe.dreamwidth.org/6931.html

    The information presented therein is incomplete at best, inaccurate and unhelpful at worst. Here's the update.

    Problem:
    Log in to your desktop (graphically, over vnc, etc) and nothing gnome related is loading properly. You see errors like:
    "Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://www.gnome.org/projects/gconf/ for information. (Details - 1: IOR file '/tmp/gconfd-oracle/lock/ior' not opened successfully, no gconfd located: No such file or directory 2: IOR file '/tmp/gconfd-oracle/lock/ior' not opened successfully, no gconfd located: No such file or directory)"

    You try gconftool-2 --spawn or similar, and receive the same error.

    You look for those files, and they don't exist.

    You edit /etc/syslog.conf to include user.* /var/log/user. You restart the syslog daemon /etc/init.d/syslog restart or service syslog restart. Reproduce the error, and open the log at /var/log/user, where you find:
    "Mar 15 10:40:51 mycomputer gconfd (root-6666): Bad permissions 711 on directory /tmp/gconfd-root"

    Solution:
    ls -ahl /tmp and look for any gconfd-{user} files. These permissions need to be private. That would look like:
    drwx------ 3 root root 4.0K Mar 15 10:53 gconfd-root
    in case you were wondering.

    To fix, chmod 700 /tmp/gconfd-{user}

    Aside:
    Annoyingly this seems to be a side-effect of installing a certain product in work. It happens every time. But now that I know how to fix it, it's all good.
    chebe: (Default)
    2010-03-14 01:36 am

    Things I Needed To Know

    Problem: Grub replaced MBR without asking.

    I'm a dual-booter. I keep the XP installation that my laptop came with because some proprietary software, especially the newest stuff, only really works on Windows. I also have a partition for work purposes, with crazy-strict security. And then, then I like to install different flavours to play around with. So happened one day I was playing with Ubuntu. Then it did something that I disliked very much, it replaced my Windows MBR with grub. But not just any grub, one with config files bloated with comments and talk of auto-updating. I quickly decided that Ubuntu (at least that release) wasn't for me*, but I couldn't delete for fear of what it would do to my booting ability. Fast forward a few months and I've managed to get the grub menu to be chain-loaded from the default Windows MBR. (I did it mostly ass-about-backwards, but these are the important steps.)


    Solution:
    1. Burn yourself a linux rescue cd, just in case. Personally I like SystemRescueCd (also, wget for Windows? *glee*). Backing up all the files in question is a good idea as well.

    2. Boot into your Linux that maintains the active grub menu. Copy the boot sector to a file (name unimportant).
    dd if=/dev/sda4 of=/mnt/external/bootfile.lnx bs=512 count=1

    3. Boot into Windows XP, copy the bootfile.lnx somewhere, and edit your boot.ini. It's probably hidden, so from cmd.exe:
    cd C:\
    edit boot.ini


    Append to end of file (under operating systems) something like:
    C:\bootfile.lnx="Linux Grub"
    Save and exit.

    4. Insert a Windows Installation disc, or Windows rescue disc. Reboot into cd. Go to the Recovery Console (R), select which Windows partition (generally 1), enter password (may be null, in which case just press return), and at prompt enter:
    fixmbr
    Accept warning. When complete, reboot.

    5. Try out your new menu.


    I am almost back to where I was. One of my Linux partitions is still buried inside the grub menu. I was unable to create a working bootfile for it to give it it's own MBR entry, but I haven't given up. Also, I did most of this in reverse order, and used the linux rescue cd to reinstall/re-setup grub on the Ubuntu partition. I don't think that was necessary, but I was/am just figuring things out. Maybe that's what allowed me to create the working bootfile? I don't know yet, but I'll keep looking.




    *(I don't intend to do any kind of flavour bashing here, this is just personal opinion. If you disagree, good, variety is, as they say, the spice of life :)
    chebe: (Default)
    2010-01-26 04:14 pm

    Things I Needed To Know

    Problem: PC system beep. Need I say more?

    Solution:

    - Immediate switch off: /sbin/rmmod -v pcspkr

    - Stop it from loading back up: vim /etc/modprobe.d/blacklist
    And append: blacklist pcspkr
    chebe: (Default)
    2010-01-12 03:05 pm

    Things I Needed to Know

    The Windows XP edition:

    Trying to do things through the command prompt, and without installing third-party tools, not always so easy. (Warning: contains some artifacts from use in batch scripts, e.g. variables:%BUILDSHARE% and running in new windows:start "" /w)

    1. Uninstalling a program.
    - Run regedit
    - Navigate to the program, something like:
    HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows > CurrentVersion > Uninstall

    - Make a note of the hex key, e.g. {4321ABCD-AB34-12CD-EF56-98769876DCBA}
    - Then from cmd.exe:
    msiexec /X {4321ABCD-AB34-12CD-EF56-98769876DCBA} /qn


    Code stays same for product through different versions. Only really useful if you're continually un/re-installing the same product.

    2.
    a. Mount a remote server.
    - start "" /w NET USE W: %BUILDSHARE%
    b. Unmount a remote server.
    - NET USE W: /DELETE
    *edit* NET USE does not play well with the Server service in Windows (particularly Server 2003). You have to stop the Server service to use it. Which, defeats the purpose of having a Server install at all.


    3. Unzipping a non-NTFS-specific compressed folder (i.e. .zip)
    - There is a way through the GUI, so far only got to opening .zip from command prompt, then use Extract All button. Opening a .zip from cmd.exe: RunDll32.exe zipfldr.dll,RouteTheCall %ARCHIVE%.zip
    - Or accept it's not happening. Buy WinZip, or install 7Zip or IZArc (my personal fave) command line utilities. IZArc: start "" /w IZArc -eh %SAVELOC% %ARCHIVE%
    chebe: (Default)
    2010-01-05 04:39 pm

    Things I Needed to Know

    On RHEL Server 5.3, if you wish to permit access from other machines on your network through a new port (one not commonly used) you add it as usual through iptables:
    /sbin/iptables -A INPUT -s 192.168.0.9 -d 192.168.0.8 -p tcp --dport 66666 -j ACCEPT

    To save the new rule to keep it past reset:
    /sbin/iptables save
    /etc/init.d/iptables save

    But, the new port will not take effect unless it is also added through the GUI. From the Desktop menu go to:
    System > Administration > Security Level and Firewall

    On the Firewall Options tab, expand Other ports, and Add your port and protocol. Apply, and OK out. Now the port should be opened immediately.



    On SLES 10.0, SP1, there is no iptables. Instead there is SuSEfirewall2. To open a port open the config file: /etc/sysconfig/SuSEfirewall2, find the line with FW_SERVICES_EXT_TCP="" (in vim normal mode type /what you're looking for, n to move through the list, N to go backwards) and add your port number to the space separated list. Exit and save. Reload rules with command: SuSEfirewall2
    chebe: (Default)
    2009-12-19 01:56 pm

    Things I Needed To Know

    Problem: USB flash drive is mounting as read-only, making it useless.

    Solution:
    0. get root permissions, su root, or run everything through sudo
    1. umount the drive
    2. df -h to find your drive
    3. fsck -a /dev/sdb
    4. mount -t vfat /dev/sdb /home/user/folder

    Be happy, you can write again!
    chebe: (Default)
    2009-12-14 01:59 am

    Things I Needed to Know

    In vim the command :TOhtml creates a syntax highlighted html version of your file. Open the html, and copy paste into OpenOffice, and you have lovely syntax highlighted code that is much easier to read.