         formatter (or from-raw-fn
                       (partial format-raw-digital digital-result-format))
         filename (value-file port)
-        raf (random-access filename)
-        gpio-port (BasicGpioPort. port filename raf formatter)]
+        gpio-port (BasicGpioPort. port filename formatter)]
+    ; Need to wait for the direction file to be available
+    (Thread/sleep 100)
     (try
-      (when direction (set-direction! gpio-port direction))
-      (when active-low? (set-active-low! gpio-port active-low?))
-      (when initial-value (write-value! gpio-port initial-value))
-      gpio-port
+      (cond-> gpio-port
+        direction (set-direction! direction)
+        active-low? (set-active-low! active-low?)
+        initial-value (write-value! initial-value))
       (catch Exception e
         (close! gpio-port)
         (throw e)))))

  (:require [clojure.core.async :as a 
             :refer [go <! >! >!! chan sliding-buffer tap]]
            [clojure.core.async.impl.protocols :as p])
  (:import [java.io RandomAccessFile FileOutputStream PrintStream]
           [java.nio.channels FileChannel FileChannel$MapMode]
           [io.bicycle.epoll EventPolling EventPoller PollEvent]))

(defn export! [port]
  (spit "/sys/class/gpio/export" (str port)))

  
  GpioPort

  (set-direction! [this direction]
    (set-direction! gpio-port direction)
    this)

  (set-active-low! [this active-low?]
    (set-active-low! gpio-port active-low?)
    this)

  (read-value [_] (read-value gpio-port))

  (write-value! [this value]
    (>!! write-ch value)
    this)

  GpioChannelProvider

  (set-edge! [this setting]
    (do-set-edge! port setting)
    this)

  (create-edge-channel [_] (tap-and-wrap-chan mult-ch (chan-factory-fn)))

  Closeable
  (close! [_]
