Показаны сообщения с ярлыком Windows. Показать все сообщения
Показаны сообщения с ярлыком Windows. Показать все сообщения

пятница, 14 апреля 2017 г.

Linking HDBC/Sqlite3 on Haskell stack under Windows

To link your Haskell application with HDBC for Sqlite3 under Windows, you have to:

install sqlite3 dev C package (headers and libs)

  • go to your Haskell MSYS2 installation (for example, D:\apps\haskell\8.0.2\msys\) and run msys2.exe
  • in opened terminal run
pacman -Syu
# if needed - close terminal and run again
pacman -Su
pacman -S libsqlite-devel
pacman -S sqlite # to have CLI tool

modify cabal and stack.yaml files

  • add to stack.yaml:
...
extra-deps: [HDBC-sqlite3-2.3.3.1]
...
extra-include-dirs: ["d:/apps/haskell/8.0.2/msys/usr/include"]
extra-lib-dirs: ["d:/apps/haskell/8.0.2/msys/usr/lib"]
...
  • add to cabal file:
  build-depends:       base >= 4.7 && < 5
                     , HDBC
                     , HDBC-sqlite3
  • now you can import modules:
import Database.HDBC
import Database.HDBC.Sqlite3
...

воскресенье, 29 января 2017 г.

Profiling of Haskell program on Windows

To profile your Haskell application on Windows w/ stack currently (due existing bug?) you must:

C:\prj> stack build --profile
C:\prj> stack exec -- prj-exe --RTS +RTS -p -RTS [other options of app]

This will produce .prof file in current directory. You can add -h and -hy to -p to get info about heap/allocations. To produce .ps file use:

C:\prj> hp2ps -c your-hp-file-name

Then open generated .ps file in SumatraPDF and analize that.. -)

воскресенье, 25 августа 2013 г.

Portable Vim (from portableapps.com) and Tools

If you use portable Vim/GVim as PortableApps.com package and want to use external tools (ctags, uncrustify, astyle, global/gtags, so on) you can setup your paths (to tools executable files) based on $HOME variable. For example lets set folder of all tools:
let TOOLSDIR=$HOME . "/vimfiles/tools"
because HOME is setted in gVimPortable/App/AppInfo/Launcher/gVimPortable.ini:
[Environment]
VIM=%PAL:AppDir%\vim
VIMRUNTIME=%PAL:AppDir%\vim\vim74
HOME=%PAL:DataDir%\settings
LANG=%PAL:LanguageCustom%
Also you can add there any other environment variables to use them in vim config file.
I usually create there - in settings/ - "tools" directory and make there "ctags", "astyle" and other folders with my external tools binaries, config files, etc...
Now you can make something like:
" Beautifiers.
exec ':cabbr astyle ' . TOOLSDIR . '/astyle/astyle.exe --options=' . TOOLSDIR . '/astyle/.astylerc'
exec ':cabbr uncr ' . TOOLSDIR . '/uncrustify/uncrustify.exe -q -c ' . TOOLSDIR . '/uncrustify/uncrustify.cfg'
for your beautifiers. Select code fragment (or all text in file) and type :!astyle for example, to see how it works.

понедельник, 16 января 2012 г.

Tcl/Tk: list of COM ports (real, virtual) on Windows

If you need helper for user like combobox with available COM ports (serial devices, and they can be real COM ports or virtual like FTDI "bridges") in Tcl/Tk, use this procedures:
# list all ports as FTDIBUS and USB. Returns list of {PortName, FriendlyName, Auto?}
# where Auto is flag - port for HMC6343 or not
proc _ls_vports {} {
    set res {}
    foreach type {FTDIBUS USB} {
        set k0 "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\$type"
        set k0ch [registry keys "$k0" {V[iI][dD]_*}]
        foreach k1 $k0ch {
            set k1ch [registry keys "$k0\\$k1"]
            foreach k2 $k1ch {
                set Class [registry get "$k0\\$k1\\$k2" Class]
                if {$Class == "Ports"} {
                    set FriendlyName [registry get "$k0\\$k1\\$k2" FriendlyName]
                    set PortName [registry get "$k0\\$k1\\$k2\\Device Parameters" PortName]
                    set Auto [expr {"silabser" == [registry get "$k0\\$k1\\$k2" "Service"]}]; #auto-detected
                    lappend res [list $PortName $FriendlyName $Auto]
                }
            }
        }
    }
    return $res
}

# Returns list of {PortName, "Com Port", 0} -
# auto-detect is impossible in this mode, no friendly name also
proc _ls_all {} {
    set serial_base "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM"
    set values [registry values $serial_base]
    set res {}
    foreach valueName $values {
        set PortName [registry get $serial_base $valueName]
        set FriendlyName "COM Port"
        set Auto 0
        lappend res [list $PortName $FriendlyName $Auto]
    }
    return $res
}
They returns list of triplets: {PortName, FriendlyName, Auto}. Auto is the flag {0|1} - 1 is for auto-detection of the silabser service (for Sillicon Labs CP210x USB-to-UART bridge chip, used in the HMC6343 demo board).

понедельник, 30 мая 2011 г.

Crossplatform software delays

This is the simple macros for different delays usuable on Unix and Windows:
#ifndef _DELAYS_H
#define _DELAYS_H

#include 
#include 

/* Converting between seconds and CPU ticks (clock_t):
 *      MS2TICKS() converts milliseconds to ticks
 *      US2TICKS() converts microseconds to ticks
 *      TICKS2MS() converts ticks to milliseconds
 *      TICKS2US() converts ticks to microseconds
 */
#define MS2TICKS(MS) ((MS)*(CLOCKS_PER_SEC)/1000)
#define US2TICKS(US) ((US)*(CLOCKS_PER_SEC)/1000000)
#define TICKS2MS(T)  ((T)/((CLOCKS_PER_SEC)*1000))
#define TICKS2US(T)  ((T)/((CLOCKS_PER_SEC)*1000000))

/*
 * delay(MS)         sleeping on MS milliseconds
 */
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
#  include 
#  define delay(MS) Sleep(MS)
#else
#  if defined(HAVE_USLEEP)
#    define delay(MS) usleep((MS)*1000)
#  elif defined(HAVE_SLEEP)
#    include 
#    define delay(MS) sleep((MS)/1000) /* granularity only ONE SECOND! */
#  else
#    error Can not found any sleep_clocks() implementation ideas
# endif
#endif

/*
 * pthread_delay(MS) sleeping thread on MS milliseconds
 */
#if defined(HAVE_PTHREAD_DELAY_NP)
#  define pthread_delay(MS) \
     do { \
             struct timespec __timespec={(MS)/1000,((MS)%1000)*1000000000}; \
             pthread_delay_np(&__timespec); \
     } \
     while(0)
#else
#  define pthread_delay(MS) delay(MS)
#endif

/*
 * unow(PNOW) store in var pointed by PNOW microseconds since Epoch
 */
#define unow(PNOW) \
{ \
        struct timeval __tv;  \
        gettimeofday(&__tv, NULL); \
        *(PNOW) = (__tv.tv_sec * 1000000) + __tv.tv_usec; \
}

#endif /*!_DELAYS_H*/
If HAVE_PTHREAD_DELAY_NP will be defined before including of this file, then pthread_delay() will be wrapper for pthread_delay_np() - see Pthreads for Win32 headers.

четверг, 26 мая 2011 г.

Wireless configuration in Windows Vista

Change in registry branch "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\ndisuio" value "Start" to 2. Then start services "Wired autoconfig", "WLAN Autoconfig" (first set to "Auto" starting mode - for autoconnecting - and now start them manually). If they doesn't start then see "Dependencies" tab and turn-on - to auto start mode all sub-services) and try again.
After this you can try to find a nets and to connect to one of them (see names of found networks). To connect you need to enter SSID and key phrase - see them in your Wireless Router config :)

See also: