Browse Source

Merge branch 'bfgminer' of github.com:luke-jr/bfgminer into bfgminer

Luke Dashjr 13 years ago
parent
commit
2a355e454e

+ 2 - 1
Makefile.am

@@ -4,7 +4,8 @@ ACLOCAL_AMFLAGS = -I m4
 EXTRA_DIST	= example.conf m4/gnulib-cache.m4 linux-usb-bfgminer \
 		  api-example.php miner.php	\
 		  API.class API.java api-example.c windows-build.txt \
-		  bitstreams/* README.FPGA README.RPC README.scrypt
+		  bitstreams/* README.FPGA README.RPC README.scrypt \
+                  api-example.py
 
 SUBDIRS		= lib ccan
 

+ 6 - 1
README.RPC

@@ -379,7 +379,7 @@ with the values after the '='
 If you enable BFGMiner debug (--debug or using RPC), you will also get messages
 showing some details of the requests received and the replies
 
-There are included 4 program examples for accessing the API:
+There are included 5 program examples for accessing the API:
 
 api-example.php - a PHP script to access the API
   usage: php api-example.php command
@@ -404,6 +404,11 @@ miner.php - an example web page to access the API
  See the end of this README.RPC for details of how to tune the display
  and also to use the option to display a multi-rig summary
 
+api-example.py - a Python script to access the API
+  usage: python api-example.py [--host HOST] [--port PORT] [command] [parameter]
+ by default it sends a 'summary' request to the miner at 127.0.0.1:4028
+ If you specify a command it will send that request instead
+
 ----------
 
 Feature Changelog for external applications using the API:

+ 1 - 1
api-example.c

@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
 		if (strcmp(argv[1], "-?") == 0
 		||  strcmp(argv[1], "-h") == 0
 		||  strcmp(argv[1], "--help") == 0) {
-			fprintf(stderr, "usAge: %s [command [ip/host [port]]]\n", argv[0]);
+			fprintf(stderr, "Usage: %s [command [ip/host [port]]]\n", argv[0]);
 			return 1;
 		}
 

+ 52 - 0
api-example.py

@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+# author: Christian Berendt <berendt@b1-systems.de>
+
+import argparse
+import json
+import logging
+import pprint
+import socket
+
+logging.basicConfig(
+         format='%(asctime)s %(levelname)s %(message)s',
+         level=logging.DEBUG
+)
+
+parser = argparse.ArgumentParser()
+parser.add_argument("command", default="summary", nargs='?')
+parser.add_argument("parameter", default="", nargs='?')
+parser.add_argument("--hostname", default="localhost")
+parser.add_argument("--port", type=int, default=4028)
+args = parser.parse_args()
+
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+try:
+    s.connect((args.hostname, args.port))
+except socket.error, e:
+    logging.error(e)
+
+try:
+    s.send("{\"command\" : \"%s\", \"parameter\" : \"%s\"}"
+            % (args.command, args.parameter)
+          )
+except socket.error, e:
+    logging.error(e)
+
+
+data = None
+try:
+    data = s.recv(1024)
+except socket.error, e:
+    logging.error(e)
+
+try:
+    s.close()
+except socket.error,e:
+    logging.error(e)
+
+if data:
+    data = json.loads(data.replace('\x00', ''))
+    pp = pprint.PrettyPrinter()
+    pp.pprint(data)

+ 11 - 0
packaging/suse/Makefile.am.patch

@@ -0,0 +1,11 @@
+--- a/Makefile.am	2013-04-04 18:03:03.676180429 +0200
++++ b/Makefile.am	2013-04-04 18:03:28.760195976 +0200
+@@ -36,7 +36,7 @@
+ if NEED_LIBBLKMAKER
+ SUBDIRS           += libblkmaker
+ bfgminer_CPPFLAGS += -Ilibblkmaker
+-bfgminer_LDFLAGS  += -Llibblkmaker/.libs -Wl,-rpath,libblkmaker/.libs
++bfgminer_LDFLAGS  += -Llibblkmaker/.libs
+ bfgminer_LDADD    += -lblkmaker-0.1 -lblkmaker_jansson-0.1
+ 
+ if HAVE_CYGWIN

+ 11 - 0
packaging/suse/Makefile.in.patch

@@ -0,0 +1,11 @@
+--- a/Makefile.in	2013-04-04 18:03:11.198185097 +0200
++++ b/Makefile.in	2013-04-04 18:03:39.020202287 +0200
+@@ -57,7 +57,7 @@
+ bin_PROGRAMS = bfgminer$(EXEEXT) $(am__EXEEXT_1) bfgminer-rpc$(EXEEXT)
+ @NEED_LIBBLKMAKER_TRUE@am__append_1 = libblkmaker
+ @NEED_LIBBLKMAKER_TRUE@am__append_2 = -Ilibblkmaker
+-@NEED_LIBBLKMAKER_TRUE@am__append_3 = -Llibblkmaker/.libs -Wl,-rpath,libblkmaker/.libs
++@NEED_LIBBLKMAKER_TRUE@am__append_3 = -Llibblkmaker/.libs
+ @NEED_LIBBLKMAKER_TRUE@am__append_4 = -lblkmaker-0.1 -lblkmaker_jansson-0.1
+ @HAVE_CYGWIN_TRUE@@NEED_LIBBLKMAKER_TRUE@am__append_5 = cygblkmaker-0.1-0.dll cygblkmaker_jansson-0.1-0.dll
+ @HAS_SCRYPT_TRUE@am__append_6 = scrypt.c scrypt.h

+ 4 - 0
packaging/suse/bfgminer.changes

@@ -0,0 +1,4 @@
+-------------------------------------------------------------------
+Thu Apr  4 17:06:56 CEST 2013 - berendt@b1-systems.de
+
+- initial package for bfgminer version 2.99.1

+ 6 - 0
packaging/suse/bfgminer.rpmlintrc

@@ -0,0 +1,6 @@
+addFilter("devel-file-in-non-devel-package")
+addFilter("no-manual-page-for-binary")
+addFilter("wrong-script-end-of-line-encoding")
+addFilter("standard-dir-owned-by-package")
+addFilter("script-without-shebang")
+addFilter("binary-or-shlib-calls-gethostbyname")

+ 90 - 0
packaging/suse/bfgminer.spec

@@ -0,0 +1,90 @@
+#
+# Copyright (c) 2013 Christian Berendt.
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon. The license for this file, and modifications and additions to the
+# file, is the same license as for the pristine package itself (unless the
+# license for the pristine package is not an Open Source License, in which
+# case the license is the MIT License). An "Open Source License" is a
+# license that conforms to the Open Source Definition (Version 1.9)
+# published by the Open Source Initiative.
+#
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
+#
+
+Name:           bfgminer
+Version:        2.99.1
+Release:        0
+Summary:        A BitCoin miner
+License:        GPL-3.0
+Group:          Productivity/Other
+Url:            https://github.com/luke-jr/bfgminer
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+Source:         http://luke.dashjr.org/programs/bitcoin/files/bfgminer/%{version}/%{name}-%{version}.tbz2
+Patch0:         Makefile.in.patch
+Patch1:         Makefile.am.patch
+
+BuildRequires:  automake
+BuildRequires:  libtool
+BuildRequires:  pkg-config
+BuildRequires:  make
+BuildRequires:  gcc
+BuildRequires:  yasm
+BuildRequires:  libjansson-devel
+BuildRequires:  libcurl-devel
+BuildRequires:  libusb-devel
+BuildRequires:  libudev-devel
+BuildRequires:  ncurses-devel
+
+%description
+This is a multi-threaded multi-pool FPGA, GPU and CPU miner with ATI GPU
+monitoring, (over)clocking and fanspeed support for bitcoin and derivative
+coins.
+
+%package devel
+Summary:        A BitCoin miner
+Group:          Development/Libraries/C and C++
+Requires:       %{name} = %{version}-%{release}
+
+%description devel
+This is a multi-threaded multi-pool FPGA, GPU and CPU miner with ATI GPU
+monitoring, (over)clocking and fanspeed support for bitcoin and derivative
+coins.
+
+%prep
+%setup -q
+%patch0 -p1
+%patch1 -p1
+%configure \
+  --enable-cpumining \
+  --enable-scrypt
+
+%build
+make %{?_smp_mflags}
+
+%install
+%make_install
+
+install -d -m 755 %{buildroot}/%{_datadir}/%{name}
+mv %{buildroot}%{_bindir}/*.cl %{buildroot}/%{_datadir}/%{name}
+mv %{buildroot}%{_bindir}/bitstreams %{buildroot}/%{_datadir}/%{name}
+
+%clean
+rm -rf %{buildroot}
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/*
+%{_libdir}/*
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}/*
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/*
+
+%changelog