Software

Using Kermit to Serial Transfer Files

I recently restored my Compaq Portable II. If you haven’t read Open (Link) about the forming of Compaq I would suggest it, I highly enjoyed it. In doing so I thought I would transfer some files to the 286 via serial, instead of taking the Compact Flash card it ran on out of the adapter, and then copying new software.

I started my journey thinking I would use the old Microsoft Interlnk software that came with MS-DOS 6.22, and then perhaps a virtual machine on laptop to serve the files. The laptop I had on hand was a Macbook Pro, I thought I could do a MS-DOS vm, then hook the USB serial adapter up to the vm allowing MS-DOS to see it as COM1. This turned into a giant headache, VMware and Virtualbox (I tried both) kept giving me errors. They really didn’t like the USB serial adapter (who does), after a few hours of playing with it I made a silly decision of: the easier way would be write a new InterLnk server in Java and let my modern OS talk to DOS directly.

I spent some time configure two Vmware Fusion vms’ to have virtual serial lines go to named pipes. Then I had socat interconnect the two pipes and log the traffic, (I put the command below if anyone is interested). On one hand, I found it interesting researching debugging serial communications using virtual machines. On the other hand, after more time than I care to admit, I didn’t see a clear pattern to the serial data, along with was getting the data going between the systems but not in a super clear format, Wireshark has spoiled me. I finally decided it was time to try another plan. A quick detour to try to decompile the app made me more confused than ever, and we were back searching for a new method of connection.

socat -v -x GOPEN:/Users/Dan/DOS/pipe GOPEN:/Users/Dan/DOS/pipe2

After researching different methods of serial file transfer, such as xmodem, ymodem, and Kermit; I thought I would give Kermit a try. I have used xmodem for dead Cisco devices, and thought Kermit would be easiest to server from my Mac. It allows things like packets in the protocol, which makes it be able to speed up and slow down transfers as the transfer goes on.

To configure the server on the laptop I used Homebrew, installing with:

brew install c-kermit

Then I loaded the app via the Compact Flash card for the Portable. I got Kermit for DOS off of http://www.bttr-software.de/freesoft/comm1.htm . Version 4 for DOS works mostly the same as version 9 from Homebrew. The app lets you change directory to a folder you want to operate out of, set your connection settings, which I have below. Then you hit the command “receive” or just “r” on one side to receive. The other side then pushes whichever file you want.

Client

set port com1           # Or COM2 or whatever the port is

set carrier-watch off   # Assume there is no carrier signal

set speed 57600         # Or whatever the speed has to be

connect

Server

set port /dev/tty.usbserial

set carrier-watch off   # Assume there is no carrier signal

set speed 57600          # Or whatever the speed has to be

connect

I selected 57600 because I was not sure if the Compaq could handle the next jump to 115200. This page has a lot of info about setting up the program, there are a lot of dials and knobs that can be moved. http://www.columbia.edu/kermit/k95faq.html

You can bring up a serial connection between the two and just type messages, but in the end I remembered how slow serial links were. I ended up powering off the system, pulling the Compact Flash card and then loading most files that way. Sort of felt like cheating, but when transferring the Windows 3.0 install files were going to be a 15 minute plus affair, I want to the good ol’ USB 3.0 Compact Flash Reader.

Advertisements

Building a Tiny Classic Mac Part 1

I saw online someone who made a tiny Mac (The Verge) and thought it looked like a neat project to attempt. I started by selecting the original Macintosh as the template I wanted to emulate. Macintosh-HelloSeveral people had made 3D models of the original Macintosh over on thingiverse.com, I used a combination of those and other sources online including photos to make a cleaned up model for myself in Sketchup. After having that model I went about breaking down how I would make it.

I recently have been using laser cutters for fun at TechShop, so I made the body of the machine out of clear acrylic. Then 3D printed a face plate that was glued onto the acrylic case. After that, it was painted with several coats of spray paint. I left the back door off so that I could work on installing the electronics, and setting up the software. That will be another article later.

The first unit I made was for myself, then two more for friends; the original one never got painted, I thought the clear body was neat and showed off the internals. It also gave me a good model to hold when working with the opaque other units.

Clear Mini Mac

Mini Mac v1

Each unit had a little screen that connected to a Raspberry Pi via a ribbon cable. Then a USB port in the front where the old unit had a keyboard port. The back had a ethernet port for updating the system itself, audio out, and micro-USB port for power. One of the hardest parts of the project was finding a ribbon cable that could handle the frequencies and work between the screen and the Raspberry Pi. A lot of the GPIO ribbon cables online actually flip what wire is in the 1 position with its neighbor; my solution was a 6 inch IDE extension cable. The cable can handle high frequencies, as well as fit the pin out perfectly.

20150918_152507000_iOS

Example Painted Side

After testing several different color paints, I ended up using Rost-Oleum Ivory Bisque semi-gloss as the beige shade. All the sides were glued together except the back, The back was held on by tiny brackets that were 3D printed and then screwed into. This allows access to the inside without breaking glue somewhere. Originally I was going to attempt to put a little handle on it, but that increased the complexity; in the end the top is flat.

All the laser cutting and 3D files I used I tracked with Git over at https://github.com/daberkow/minimacparts . I will put a few photos of the clear unit below, and of the final unit. Then later post another article about the electronics, and software to run it. There are also photos of the many many attempts at different sized bodies and painting side panels. My original model was almost exactly 1/3rd scale. Then I had to make it a tiny bit bigger because of the screen I used.

Standard disclaimer that I do not own or hold any rights for the Macintosh name, or Apple logo. I do this as a fan for fun.

Parts:

  • Screen, JBtek® Latest Version 4 ” inch IPS Display (Super TFT) 480×320, (Amazon)
  • Screen Cable, IDE Extension Cable, (Amazon)
  • Audio Cable, 3.5mm right angle cable (Amazon)
  • USB Extension cable, with 90 degree plug so that it fits in the case (Amazon)
  • Micro USB extension for power, with 90 degree head (Amazon)
  • For ethernet I made my own cable, it had a RJ45 head and a RJ45 keystone for the back

 

Updated Windows Sudo

Recently I updated my Windows sudo program and added a command for Super Conduit, this is what I call some tweaks that you can make to a Windows Vista+ system. This allows someone to copy sudo.exe to a systems, system32 folder; then after running “sudo cmd” you can run “sudo /write” so add ls, ifconfig, and superc as a option in the command line.

Superc has options of enable, disable, and show. Making it easy to run. 🙂

Newest build is always here https://github.com/daberkow/win_sudo/raw/master/sudo/sudo/bin/Release/sudo.exe

VM Experimentation

I am the type of programmer/IT person who enjoys having all my experimentation of systems done inside a virtual machine. That way if I break something, I can easily role back the virtual machine or just delete it. As seen in my last post, I recently built a new NAS. The original plan was to turn my old server into a Proxmox or ESXi box, the downside to that plan I found out quickly; the old box used DDR2, and at this point to get DDR2 memory it is quite expensive. That, along with my worry of power usage on the old box, I decided to give another solution a try.

After researching around I found my local Fry’s Electronics had the Intel NUC in stock. This is a tiny tiny PC that can take up to 16GB of RAM, has an Intel Core i5, and only uses 17 Watts. The box also has Intel vPro; what is vPro you ask? vPro allows you to remotely manage the system, so I can remote into it without buying a fancy management card, I can also remote power the box on and off, or mount a virtual CD. not bad for a ~$300 box. The model I got, DC53427, is a last gen i5, so it was a little cheaper, at the cost of having only 1 USB 3.0 port. It came with a VESA mount, so the NUC could be attached to the back of a monitor, that was a nice feature. I got USB 3.0 enclosure for 2 older 500GB hard drives, and used those as my storage. I installed Proxmox  on the system since my work has been starting to use that software more and more, and this was a chance for me to learn it.

A quick note about Proxmox to those who have not used it, I had come from a VMWare background so my work was my first experience with Proxmox. It is a free system, the company offers paid subscriptions for patches and such, without that the web page bothers you one time when you login, and you just dismiss the message. The software is a wrapper around KVM and some other Linux virtualization technologies. It can handle Windows and Linux systems without a problem. The interface is completely web based, with a Java virtual console; if you don’t update to the latest patches the java console can break with Java 7 Update 51. The software works well enough. There are still some areas that is needs improvements; in VMWare if you want to make a separate virtual network you can use their interface, on Proxmox that’s when you go to the Linux console and start creating virtual bridges. But once I got everything working, it seemed to work well. I don’t know how long I will keep it without trying another system, but for now it is nice. Since the system relies on KVM, it can do feautres like Dynamic memory allocation, if a VM is only using 1 GB of ram but is allocated 6, it will only take 1GB at that time. Also KVM can do deduplication of memory, so if two VMs are running the same OS, it only stores those files in memory once, freeing up more memory space.

I ran into one problem during install of Proxmox, the NUC is so fast, that it would start to boot before the USB 3.0 hard drives had been mounted. After searching around everywhere I found a fix on http://forum.proxmox.com/threads/12922-Proxmox-Install-on-USB-Device; adding a delay in the GRUB boot loader allows enough time for the system to mount the LVM disks correctly and then start. At first I just went to the Grub boot menu, hit “e” then added “rootdelay=10”, to the “linux /vmlinuz-2.6.32-17-pve root=/dev/mapper/pve-root ro rootdelay=10 quiet” line. After the system loaded I went into /Boot and added the same entry to the real Grub menu. Now I had a Intel NUC with 1TB of storage and 16GB of RAM. I could have used the NAS with iSCSI, but that was a lot of config I didn’t want to do; along with, I was setting up some Databases on the system and didn’t want the overhead of using the NASs RAIDZ2 at this time.

I have been using it for a few weeks, and its a nice little box. It never makes a audible level of noise (although it does sit next to its louder brother the NAS). Down the road if I want more power I can always get another NUC and put Proxmox into a clustered mode. These boxes keep going down in price and up in power, so this can grow with my needs.

Java Windows Shortcut Library (Parsing and Creating!)

Recently I have been working on a project that involves extracting a bunch of files from zips. The problem I faced was all the shortcuts within the zips were hard coded to locations, making it impossible for me to move the extracted zip data to wherever I may want. I wanted a native library that could read and modify Windows Shortcuts so I could drop my zip data anywhere; my project is in Java, and its instant cross compatibility was needed. I know all my clients have Java installed, so that made its dependency not a issue. After looking around on the internet and finding several options, including the popular https://github.com/jimmc/jshortcut. Now the downside the this popular jShortcut library is you need a DLL, why you need a DLL to write a binary file, I am not sure. More specifically, you need a DLL for your PCs instruction set, ick! After searching the far reaches of github, and getting to the end of my rope I found https://github.com/kactech/jshortcut, written 5 years ago, and not really popular on github I thought I would give it a try. IT’S AMAZING! With no dependencies, and just a single include, you can write, modify, and create new Windows Shortcuts! There is example code included, and it couldn’t be easier to use. I just wanted to make sure anyone who has had the same problem knows about this great library.

WQL, SQL Queries for Windows Backend (Part 1)

If you have been writing web apps for a while, or other apps you more than likely have used SQL. SQL allows you to query a database and interact with your applications data. Instead of trying to find a users profile, what if we wanted to find out what a user was printing on their local machine? If there was an easy interface for that, it could make programming for a platform like Windows a lot easier. Well Microsoft years ago added this ability to Windows; the technology is called WQL. This was added with the other components of WMI (Windows Management Instrumentation) at Windows ME. For Windows 9x and NT you can download the WMI core. This article will be a brief over view of what it can do and how you can play around with it.

First like when we looked at LDAP, we want a tool that will let us quickly play around with what is available, and then code that into our application. The tool I use is WMI Explorer, http://www.ks-soft.net/hostmon.eng/wmi/, it provides a easy interface to look at all the data available. With the WMI core it works with everything back to Windows 95! You can download and run the program for free, no installation required. Once open, there is a upper portion of the window that lists all the spaces you can access, these would be the ‘tables’ in SQL. Depending on your version of Windows, there will be separate options available. I have used this interface before for network cards (6to4 Cleaner) and printers.

WMI Explorer

WMI Explorer

For this example I will go over to the Win32 framework and access the Win32_Printer ‘table’. I get a list of printers the machine has installed, as well as attributes to each of these printers. Any administrator, or any program attempting to manager printers (I say attempting because printers can he a horrible experience) information – like what port the printer is using – is here, in addition what type of connection this machine has to the printer. At the bottom of the Window there is a Query that is building as you select different fields. This query can be moved into a application later to get the same data in code. WMI Explorer also allows for a user to write Queries directly without this interface; that is the second tab at the top of the window.

One downside I have found in using WMI is the setup process time, in C#/.NET using WMI is easy, but it takes time to start accepting queries. About a year or two ago I was working on querying network card information on Windows Vista. The first call could take a few seconds to respond, after that first call it would speed up, this is just something that has to be accounted for in the applications design. I found running WQL queries in a separate process, and starting them as soon as possible would allow the process to finish before the user needed the data.

I just wanted to get everyone started looking at what is available, in a later article I will go into more depth about programming with this and how you can interact with this data in a C#/.NET program.

RPI phpCAS Authentication Tutorial

After much tinkering with RPI’s CAS (Central Authentication System) in PHP, I thought I would put together a guide to make it easy for anyone to put together a site that uses it. This would work for anyone at another location with a CAS server, but this example is for RPI.

  1. Get the CAS Library
  2. Download the tar file under “Current Version”
  3. Extract the contents, using a program such as 7-Zip, and put it in the root of whatever web folder you want
  4. Download the latest CA bundle for SSL
  5. Create a index.php, login.php, logout.php
  6. The index has to load the library, check if the user is logged in, then print out text.
    • <?PHP

      include_once(“./CAS-1.3.2/CAS.php”);
      phpCAS::client(CAS_VERSION_2_0,’cas-auth.rpi.edu’,443,’/cas/’);
      // SSL!
      phpCAS::setCasServerCACert(“./CACert.pem”);//this is relative to the cas client.php file

      if (phpCAS::isAuthenticated())
      {
      echo “User:” . phpCAS::getUser();
      echo “<a href=’./logout.php’>Logout</a>”;
      }else{
      echo “<a href=’./login.php’>Login</a>”;
      }

      ?>

       

    • First we load the library for CAS from the subfolder
    • Then we select which will be our central server
    • We have to select our ca bundle, setCasServerCert does this
    • Now we have fully loaded and configured the library
    • Finally, I can ask CAS if a user has logged in, if so writeout some options, if not others
  7. This is the login page
    • <?PHP

      include_once(“./CAS-1.3.2/CAS.php”);
      phpCAS::client(CAS_VERSION_2_0,’cas-auth.rpi.edu’,443,’/cas/’);
      // SSL!
      phpCAS::setCasServerCACert(“./CACert.pem”);//this is relative to the cas client.php file

      if (!phpCAS::isAuthenticated())
      {
      phpCAS::forceAuthentication();
      }else{
      header(‘location: ./index.php’);
      }

      ?>

       

    • Similar setup of authentication as before
    • Now we check if the user is NOT authenticated, if the user is not authenticated we force login
    • If the user already is logged in, then we redirect to the index
  8. The logout page:
    • <?PHP

      include_once(“./CAS-1.3.2/CAS.php”);
      phpCAS::client(CAS_VERSION_2_0,’cas-auth.rpi.edu’,443,’/cas/’);
      // SSL!
      phpCAS::setCasServerCACert(“./CACert.pem”);//this is relative to the cas client.php file

      if (phpCAS::isAuthenticated())
      {
      phpCAS::logout();
      }else{
      header(‘location: ./index.php’);
      }

      ?>

       

    • Same configuration (this can be done by including a core file that everything else calls, but for this example I wanted to keep it simple)
    • If they are not logged in, then we push the user back to login

That is the basic configuration, the example is available for download below. If there are any questions feel free to post a comment.

Download: http://programs.buildingtents.com/CASExample.zip

Extra Notes:

  • If you want to save server space, the docs folder under the CAS folder can be removed
  • I have ran into problems with CAS on a Windows Apache server, and CAS on a Linux Apache server reference the CACert.pem file differently