Go to advanced search

by BlackJack
Thu Sep 27, 2012 8:16 am
Forum: General programming discussion
Topic: Non X menu system
Replies: 2
Views: 999

Re: Non X menu system

@clacktronics: I would say it is called *text user interface* or *text UI* or *TUI*. It has nothing to do with Bash or the shell but the terminal (emulator). As this is Linux you can peek at the source code to see how it is done. ``raspi-config`` is a shell script, so here it is really easy to look ...
by BlackJack
Thu Sep 27, 2012 7:11 am
Forum: General programming discussion
Topic: Best Programming Language to learn?
Replies: 24
Views: 24197

Re: Best Programming Language to learn?

@ggiwebsinfo: That question is hard to answer. It depends on what programming languages you already know, what you expect from a new programming language, which ones „model” and idiomatics match your way of thinking better, and so on. There is no best programming language, not without setting some c...
by BlackJack
Thu Sep 27, 2012 6:52 am
Forum: Python
Topic: Python program help!
Replies: 13
Views: 3541

Re: Python program help!

@Oddblob: Although raspberrypiguy1 shouted his advice the `input()` line is a bad „solution”. It works until you have an error in your program leading to a traceback before that line is reached. Then you have the very same problem again — the terminal window closes before you have the chance to read...
by BlackJack
Wed Sep 26, 2012 3:35 pm
Forum: Python
Topic: Python program help!
Replies: 13
Views: 3541

Re: Python program help!

@Oddblob: Open a terminal and start the program there. Then it will stay open even after the program is finished.
by BlackJack
Wed Sep 26, 2012 10:32 am
Forum: Python
Topic: Reading files into lists etc?
Replies: 6
Views: 1125

Re: Reading files into lists etc?

@Mattylad: I think you will need basic Python skills and an understanding of the basic data types (`int`, `str`, `float`) and container types (`str`, `list`, `tuple`, `dict`, `set`). The tutorial in the Python dokumentation gives a tour through all this, but beginners might find tutorials like Learn...
by BlackJack
Wed Sep 26, 2012 9:04 am
Forum: General programming discussion
Topic: Owcapi.h
Replies: 7
Views: 1862

Re: Owcapi.h

@Darranking: If you don't tell the linker which libraries to link in it does not even search for them. :-)

Your code is okay as a test, but for production code I would pay more attention to return values indicating errors.
by BlackJack
Wed Sep 26, 2012 8:53 am
Forum: General programming discussion
Topic: Model-View-Controller Interfacing
Replies: 1
Views: 480

Re: Model-View-Controller Interfacing

Usually you are using references to the objects and/or pass callbacks around to decouple components. This also depends on the programming language(s) in use and the complexity of the project. Decoupling everything to the maximum in the most generic way may be overkill for a small project and when it...
by BlackJack
Wed Sep 26, 2012 8:44 am
Forum: General programming discussion
Topic: Socket advice
Replies: 5
Views: 1422

Re: Socket advice

@mitchnufc: Any programming language able to use sockets can be used. Maybe even any language able to read and write to files if you use something like ``socat`` to connect the socket with your program. Maybe you are thinking too low level here. Instead of using sockets directly, or even wonder abou...
by BlackJack
Wed Sep 26, 2012 8:25 am
Forum: Python
Topic: WiringPython - WiringPi for Python
Replies: 205
Views: 60129

Re: WiringPython - WiringPi for Python

@alexeames: ``pip`` is not replacing compiling and installing — it is doing exactly that.
by BlackJack
Mon Sep 24, 2012 10:33 pm
Forum: Python
Topic: Help needed, I am trying to make a timer!
Replies: 3
Views: 894

Re: Help needed, I am trying to make a timer!

@Pellski: Especially for small code snippets you should use the `timeit` module from the standard library. It runs the code in a loop long enough to get a meaningful average time per execution and repeats this several times and picking the best result of those to counter the effect of a multitasking...
by BlackJack
Mon Sep 24, 2012 8:34 pm
Forum: General programming discussion
Topic: Owcapi.h
Replies: 7
Views: 1862

Re: Owcapi.h

@Darranking: That file is in the `libow-dev` package.
by BlackJack
Mon Sep 24, 2012 7:46 pm
Forum: Python
Topic: Python code to determine board revision
Replies: 18
Views: 4761

Re: Python code to determine board revision

@MattHawkinsUK: Okay, I did not know that not just the firmware revision is encoded into that value. So just the last four digits: def get_revision(): with open('/proc/cpuinfo') as lines: for line in lines: if line.startswith('Revision'): return int(line.strip()[-4:]) raise RuntimeError('No revision...
by BlackJack
Mon Sep 24, 2012 5:43 pm
Forum: Python
Topic: Python code to determine board revision
Replies: 18
Views: 4761

Re: Python code to determine board revision

@Grumpy Mike: With more pythonic I meant using the features of Python to write more robust, shorter, and more readable code. It seems your definition of readable does not match the idea of the Python developers or Python programmers which choose the language because of that language features. It may...
by BlackJack
Mon Sep 24, 2012 8:17 am
Forum: C/C++
Topic: gcc bug ?
Replies: 3
Views: 934

Re: gcc bug ?

@Yoyo: That's why I always use ``-Wall -Wextra``: $ gcc -Wall -Wextra -O3 test.c test.c: In function ‘setup_io’: test.c:142: warning: pointer targets in assignment differ in signedness test.c: In function ‘main’: test.c:69: warning: control reaches end of non-void function test.c:41: warning: ‘sum’ ...
by BlackJack
Mon Sep 24, 2012 8:10 am
Forum: Python
Topic: Python code to determine board revision
Replies: 18
Views: 4761

Re: Python code to determine board revision

A more pythonic and usable version: def get_revision(): with open('/proc/cpuinfo') as lines: for line in lines: if line.startswith('Revision'): return int(line[line.index(':') + 1:]) raise RuntimeError('No revision found.') def get_board_revision(): revision = get_revision() if revision in (2, 3): r...
by BlackJack
Sun Sep 23, 2012 10:45 am
Forum: Python
Topic: Converting quaternion to yaw/pitch/roll
Replies: 4
Views: 4934

Re: Converting quaternion to yaw/pitch/roll

@cTn: Operators are explained in the Python documentation: http://docs.python.org/library/stdtypes.html#index-15 The index of the documentation is helpful to find such information. ``**`` is the power operator. As the classes don't just have members but also methods, they are obviously not just for ...
by BlackJack
Sun Sep 23, 2012 8:19 am
Forum: Python
Topic: Converting quaternion to yaw/pitch/roll
Replies: 4
Views: 4934

Re: Converting quaternion to yaw/pitch/roll

@cTn: It seems to be pretty straight forward. Something like this: from math import atan, atan2, sqrt # # Fill in definitions for `Vector` and `Quaternion` classes here... # def get_gravity(quaternion): return Vector( 2 * (quaternion.x * quaternion.z - quaternion.w * quaternion.y), 2 * (quaternion.q...
by BlackJack
Sun Sep 23, 2012 7:52 am
Forum: Other programming languages
Topic: Lazarus and Lnet
Replies: 3
Views: 3018

Re: Lazarus and Lnet

@bernd331: It's not clear from your post if you know by now what the ``INSTALL`` file contains: Usually it is a text file for humans to read, explaining how to compile/install the software. Just like the other typical, all upper case filenames with no file extension are text files targeted at humans...
by BlackJack
Thu Sep 20, 2012 7:19 am
Forum: C/C++
Topic: Caveat: Porting Visual Studio C/C++ code over to the Pi
Replies: 11
Views: 1932

Re: Caveat: Porting Visual Studio C/C++ code over to the Pi

@Janq: I would not call cc65 „only c-like”. It tries to be as close to the ISO standard as it is sensible given the target's limitations. It is much closer than other compilers I have seen for those ancient platforms which call themselves „C compiler”.
by BlackJack
Thu Sep 20, 2012 7:07 am
Forum: C/C++
Topic: bcm2835 Problem
Replies: 2
Views: 1007

Re: bcm2835 Problem

@Kampfwurst: You extract *the* tar.gz file? Which one?

Have you confirmed there is no ``configure`` in that directory? Have you changed the working path to that directory with ``cd`` before?
by BlackJack
Thu Sep 20, 2012 7:02 am
Forum: Python
Topic: Can's start IDLE from the command line
Replies: 1
Views: 2926

Re: Can's start IDLE from the command line

@modeltmaniac: Idle is a GUI program, so it won't run in the terminal. If you are on a Linux system with a running X and connect to the Raspi via ``ssh`` you can give the option ``-X`` to start GUI programs on the Raspi displaying their GUI on your end of the connection. Another solution to get a GU...
by BlackJack
Thu Sep 20, 2012 6:56 am
Forum: Python
Topic: how to change voice using festival in Python
Replies: 6
Views: 3878

Re: how to change voice using festival in Python

@gians: Using `subprocess` like this has all the problems and security risks `os.system()` has. You should not use ``shell=True`` or you have to take care what to escape from the shell. Untested: from subprocess import PIPE, Popen text = 'We love Raspberry.' process = Popen(['festival', '--tts'], st...
by BlackJack
Thu Sep 20, 2012 6:43 am
Forum: General programming discussion
Topic: Testing if a variable is not equal to more than one number
Replies: 5
Views: 1240

Re: Testing if a variable is not equal to more than one numb

@Sremos: That is either a security risk — in Python 2 because `input()` executes the input from the user as code in the context of your program — or it won't work — in Python 3 because `input()` was changed return just the user input as string like `raw_input()` did in Python 2. In Python 2 you shou...
by BlackJack
Tue Sep 18, 2012 10:26 pm
Forum: C/C++
Topic: Caveat: Porting Visual Studio C/C++ code over to the Pi
Replies: 11
Views: 1932

Re: Caveat: Porting Visual Studio C/C++ code over to the Pi

Commodore 64? Mine doesn't look dead. :-)
by BlackJack
Tue Sep 18, 2012 7:47 am
Forum: Python
Topic: Adafruit Basic Resistor Sensor Reading on Raspberry Pi
Replies: 11
Views: 1838

Re: Adafruit Basic Resistor Sensor Reading on Raspberry Pi

@Saulverde: You posted the code without indention, but indention is important in Python. Otherwise it is not clear which code belongs to which function or loop or any other ”block construct”.

There is no send or output pin defined. As it is about *reading* a sensor, I do not see why you expect one?

Go to advanced search