w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Twisted Python script on Raspberry Pi (Debian) to communicate with Arduino via USB
Judging from this: http://twistedmatrix.com/trac/browser/tags/releases/twisted-12.3.0/twisted/internet/_win32serialport.py#L84 you should be looking at dataReceived(self,...) method of your Protocol subclass Thus: class USBclient(Protocol): def connectionMade(self): global serServ serServ = self print 'Arduino device: ', serServ, ' is connected.' def cmdReceived(self, cmd): serServ.transport.write(cmd) print cmd, ' - sent to Arduino.' pass def dataReceived(self,data): print 'USBclient.dataReceived called with:' print str(data) try this to see if it works.

Categories : Python

migrating code from Microsoft Visual C++ to debian (raspberry)
As your code does not depend on anything other than opencv, you can just leave out the stdafx header. it's a feature of visual studio that you dont need here. ( see Purpose of stdafx.h ) it compiles fine on my machine. with: #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv/cv.h> note the "/". please use these instead of backslashes here, or unix machines will complain. also: use g++ to compile this code, not gcc.

Categories : Linux

Linux/Raspberry Pi Networking
You have one Pi with the smb share and another one which have to write to that smb share, right? A simple solution is to mount you smb share at the second Pi. (scais solution) To do that you need the cifs package (ask google for a download link, i don't know which os is installed on your second pi) After installation add a new entry to /etc/fstab with this syntax //<server-IP>/<share> <mountpoint> cifs noauto credentials=</path/to/.smbcredentials> 0 0 In .smbcredentials you can store the username and the password (if your share is password protected) username=<username> password=<password> To automount the share while booting remove the "noauto"-option but if you start the pi and it can't reach the share your boot-process will take much time. My

Categories : Linux

load xml to mysql under debian linux
The XML file you are trying to import is not formatted using a schema that MySQL knows how to import. You will need to convert it yourself. The formats that MySQL will recognize are defined here: http://dev.mysql.com/doc/refman/5.5/en/load-xml.html

Categories : Mysql

How to setup GIT server on Linux Container in Debian
You may want to read this HowTo of setting up GIT server on Debian

Categories : GIT

Openshift and Play Framework (on Debian Linux)
remote: Error: OPENSHIFT_LOG_DIR not defined The OPENSHIFT_LOG_DIR is not defined, so the hook fails. Take a look at your .openshift/action_hooks/start to see if you're defining OPENSHIFT_LOG_DIR or OPENSHIFT_DIY_LOG_DIR. There appears to be a discrepancy between the two, as seen in this issue on Github

Categories : GIT

Web Service with Java 1.6 and Tomcat6 in Debian / Linux
I Assume you are trying to deploy to tomcat. Have you used any frameworks to convert your java program into a web service? Is there any " .wsdl " file which you can locate? Create a java class with a string variable setter and getter Expose this class as a webservice (Can be done by any frameworks ex: axis, cxf etc.) The framework provides with a wsdl file and a war if you built it. Then deploy war file to any server. Did you miss the points 2 & 3 ?

Categories : Java

qemu on Raspberry Pi Arch Linux latest sd image
In case archlinux-hf-2013-07-22.img Here there 3 partion are made. you can check by using fdisk -l archlinux-hf-2013-07-22.img rootfs is in sd5 i.e 5th partion. So pass this parameter "root=/dev/sda5 panic=1" , it will boot perfectly.

Categories : Linux

Building uclibc linux 3.10-2 (Debian jessie x86_64) fails due to missing types
It's hard to say where the error comes from without looking carefully at the code in question. Most likely is a case that the package itself is not compatible with the environment within which you are attempting to build the software. With that said, it's possible to track it down, if you are willing to do so. From there, the solution is likely either changing settings at the start of the build process, or modifying the code to correct a mistake. This problem is tricky to track down since it's a third-party package performing the includes. And, if it's written to build on multiple architectures, it will likely contain a lot of preprocessor directives that make it hard to even know which code is actually being used. I recommend capturing the command that generates the error (looks li

Categories : C

Get OS name with C [Linux, portable for distros: Centos, Debian, Fedora, OpenSUSE, RedHat, Ubuntu]
You could try to use popen(3) to run and read the output of command /usr/bin/lsb_release -ds. If that fails, you might read and parse /etc/issue Notice that clever or paranoid sysadmins might edit and configure that /etc/issue file at will. But I don't understand why you want to know all that (from inside a C program), in other words, why the uname syscall is not enough. In particular, there are a lot of Debian (or Redhat) derived specialized distributions, and I don't understand why the name of the particular distribution would matter to a C program. It matters much more for packaging purposes....

Categories : C

What is changelog.Debian.gz file during debian packaging?
When packing in debian, inside your project directory there's a directory named debian, which is where we keep files regarding instructions of how to pack your software, as well as relations with other packages, etc. We can call it you package control files. Among them, there's one called changelog, which looks like this: mypackage (version-revision) unstable; urgency=low * Changelog messages -- Your Name <your@email.com> Mon, 13 Aug 2012 14:09:01 -0300 (...) This file is used by the packaging software (dpkg-buildpackage) to know the name and version of your package. It also has info like the mantainer, changelogs, etc. After you build the package and install it, this file will be located at /usr/share/doc/mypackage/changelog.Debian.gz compressed in gzip format. You can che

Categories : C++

NFC tag reading in python on raspberry pi
There are lots of links on google wherein you can find information on data format used in NFC. Some of them are http://learn.adafruit.com/adafruit-pn532-rfid-nfc/ndef http://developer.nokia.com/Community/Wiki/Understanding_NFC_Data_Exchange_Format_(NDEF)_messages

Categories : Python

Python ssl login hanging on Debian
So things look ok on Fedora: [bharrington@leviathan ~]$ python Python 2.7.5 (default, Aug 22 2013, 09:31:58) [GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mechanize >>> br = mechanize.Browser() >>> br.open("https://wwws.mint.com/login.event") <response_seek_wrapper at 0x29b6440 whose wrapped object = <closeable_response at 0x29b6320 whose fp = <socket._fileobject object at 0x298d150>>> >>> br.title() 'Mint > Start Here' >>> Which leads me to wonder about the SSL/OpenSSL libraries in use. Just to test it out can you run from the command line: $ openssl s_client -connect wwws.mint.com:443 You should see the SSL certificate for mint di

Categories : Python

Raspberry Pi Python PWM RuntimeError: No access to /dev/mem
The problem is with the code above is that I forgot to set RED to at output before trying to use it. The error message did not help resolve this problem. Next time, I need to remember to setup PWM pins as outputs before trying to use them.

Categories : Python

Python console output gets overwritten in Debian 6
This might not be the exact solution and I'm pretty sure there'll be a better solution but i think if you try sleep after your last apt-get statement, it might work. As per your code: import time subprocess.call("pip install phpserialize &> /dev/null 2>&1", shell=True) subprocess.call("pip install requests &> /dev/null 2>&1", shell=True) subprocess.call("apt-get install git -y &> /dev/null 2>&1", shell=True) time.sleep(5) import phpserialize import requests from phpserialize import serialize from phpserialize import unserialize def checktext(): text = raw_input(" Enter your text:") return text itext = checktext() That causes the whole apt-get to execute first and then moves on to your text=... statment. Hope this helps

Categories : Python

Using Python smbus on a Raspberry Pi - confused with syntax
I'm absolutly not sure this is the problem, but according to the specs p22: MMA7660FC is read using it’s internally stored register address as address pointer, the same way the stored register address is used as address pointer for a write. The pointer generally auto-increments after each data byte is read using the same rules as for a write (Table 5). Thus, a read is initiated by first configuring the device’s register address by performing a write (Figure 11) followed by a repeated start. The master can now read 'n' consecutive bytes from it, with the first data byte being read from the register addressed by the initialized register address. As far as I understand, to "read" from a register, you have to start by writing the register address, and then blindly read a byte

Categories : Python

Raspberry PI: PHP call python script with sudo
Mm, i have try with this two simple example: /Scripts/test.py #!/usr/bin/env python print (str('hello world')) /var/www/test.php <?php echo shell_exec('/Scripts/test.py'); ?> via a browser, show me "hello world" Perhaps try this: chmod a+x your_py_file.py Hope that help..

Categories : Nginx

How to compile Python 2.4.6 with ssl, readline and zlib on Debian Lenny
I found the solution here: I changed setup.py, looking for the first assignment to the lib_dirs variable, changing it like so: lib_dirs = self.compiler.library_dirs + [ '/lib64', '/usr/lib64', '/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu', # added '/usr/lib/i386-linux-gnu', # added ] Then I repeated the whole thing, starting with setup.py clean, and it worked.

Categories : Python

No video file created by OpenCV 2.3.1 with Python on Raspberry Pi
I eventually went through and tried all of the fourcc codecs and none worked. Same with the mpeg2 codec. I ended up using avconv to create and capture the video with this line: import os os.system("avconv -f video4linux2 -input_format mjpeg -i /dev/video0 output.avi") os.system() is used to run a terminal command. OpenCV can still be used to process the video files at a later time. Hope this helps someone.

Categories : Opencv

Running Python script causes Raspberry Pi to lose power
I tried your script. It locks up the rpi at this line GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_DOWN) GPIO06 isn't one of the pins on the GPIO port. You'd have look at the schematic to see what it's connected to. Looks like it's LAN_RUN. What are you trying to do with it? From elinux.org GPIO06 is LAN_RUN and is available on pad 12 of the footprint for IC3 on the Model A. On Model B, it is in use for the Ethernet function. So unless you have a model A, you shouldn't be using GPIO06

Categories : Python

How can I create an architecture dependant Debian package for my Python extension?
Architecture: all is for platform-independant packages. Try Architecture: any. See: Debian Policy Manual : Chapter 5 - Control files and their fields

Categories : Python

Raspberry pi will not send serial data to an arduino using either minicom or python
You need to read up on the difference between arduino and raspPI 'serial' pins - in short, their voltage levels are quite different and require a conversion cable between the two of them to adjust these levels.

Categories : Python

Linux. How to disable all log?
Stop Log Daemon syslogd. For example by using init-scripts: /etc/init.d/syslogd stop Depending on your Linux-Dist this can be achived in different ways. For disable logging permanantly (embedded system with low disk space) remove loggind deamons, edit /etc/defaults or remove init scripts from the rc (runlevel-configuration) directories. Edit: much more of interest would be, what causes your latency problems. I do not believe the logs would cause this. Run "top -d1" and check the most upper processes. A network home server for example would probably not need the XWindow System. If you are not running web-development on this machine also Database and Webser will probably be of no need... A lot of processes can cause lags.

Categories : Linux

How can I make a connection between Raspberry Pi and a Bluegiga WT11i Bluetooth Module using Python?
Got it!! pi@raspberrypi ~ $ aptitude install bluetooth pi@raspberrypi ~ $ hcitool dev Devices: hci0 00:07:80:54:CA:E2 pi@raspberrypi ~ $ hcitool scan Scanning ... 00:07:80:54:CA:E2 BGWT11i pi@raspberrypi ~ $ bluez-simple-agent hci0 00:07:80:54:CA:E2 Enter PIN Code: 1234 Now I can connect ... pi@raspberrypi ~ $ python rfcomm-client.py 00:07:80:54:CA:E2

Categories : Python

Disable Linux Mint Alt-F1 shortcut
As CharliePrynn pointed out, superuser.com would be a better place for this question. I actually found the solution there: http://superuser.com/questions/531874/disable-alt-f1-keyboard-shortcut-in-cinnamon: gsettings set org.gnome.desktop.wm.keybindings panel-main-menu "[]" plus logout & login

Categories : Intellij Idea

Python having trouble accessing usb microphone using Gstreamer to perform speech recognition with Pocketsphinx on a Raspberry Pi
So I finally got this guy working. Couple key things I needed to realize: 1. Even if you're using Pulseaudio on your Raspberry Pi, as long as Alsa is still installed you're still able to use it. ( This might seem like a no brainer to others, but I honestly didn't realize I could still use both of these at the same time ) Hint via (syb0rg). 2. When it comes to sending large amounts of raw audio data ( .wav format in my case ) to Pocketsphinx via Gstreamer, (queues) are your friend. After messing around with gst-launch-0.10 on the command line for a while I came across something that actually worked: gst-launch-0.10 alsasrc device=hw:1 ! queue ! audioconvert ! audioresample ! queue ! vader name=vader auto-threshold=true ! pocketsphinx lm=/home/pi/dev/scarlettPi/config/speech/lm/scarlett

Categories : Python

Porting Python Raspberry Pi application to Twisted - how to handle background threads that poll the hardware
You can use LoopingCall (howto) to schedule a repeated function call on a certain interval. This probably replaces your polling threads entirely.

Categories : Python

How to convert/compile 64-bit python (2.7.4) as 32-bit python on linux?
You need proper so files for proper OS. Cant use just like that.. You need 64 bit libexpect5.44.1.9.so file from 64 bit machine. and load it before executing your code. You can also bundle up 64 bit libexpect5.44.1.9.so using sdx binary and keep loading it at the time of invocation.

Categories : Python

How to disable/restrict a line of code after it has been run? (Python)
Associate each challenge with a boolean flag. Set the flag to True when the player finishes the challenge, and check the flag before giving the player the option to do the challenge again. For example, if you had a "punch monkeys" quest, you might have the following flag: monkeys_punched_yet = False When the player punches the monkeys, you'd set monkeys_punched_yet = True In the monkey-punching area, you'd have a check something like this: if monkeys_punched_yet: description_text = ("You see a pile of bruised and battered monkeys " "in a corner of the room.") else: description_text = "You see a group of unsuspecting, punchable monkeys." options.append("punch monkeys")

Categories : Python

Executing a python file from PHP - Linux
This is most likely a permission issue. Try echo exec("whoami"); This will let you know who php is running as. Then you need to verify this user can run the python script. If the file was not created by the same daemon that runs python, you will most likely be denied permission. Update This will let you know who owns all the files you are working with. The file being written to needs to be writable by the user that is running python. If you are running python from ssh, that is most likely not the same user as when you run python from exec. echo exec('whoami') . "<br>"; echo exec("ls -l test.txt") . "<br>"; echo exec("ls -l somefile.py") . "<br>"; Update 2 Because I constantly forget this exists. passthru('python somefile.py 1 2>&1'); This will e

Categories : PHP

how to run a python program in linux crontab?
You need a correction : * * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py to run it every minute. Your cron statement : 1 * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py would run it only at first minute of every hour eg 09:01, 10:01...etc. Hence, you will have to wait 1 hour to see the result.

Categories : Python

installing gedit in linux with python 2.7.3
As far as I know gedit is installed by default. Try type gedit in a terminal and see if it opens. alternatively in a terminal type sudo apt-get install gedit This will install Ubuntu's current favorate version of gedit. In either case this wont get you the latest version but unless you are super keen on the latest version for some reason then don't worry about it. If you do want the latest version you need to install python3 first in which case this should help: http://askubuntu.com/questions/244544/how-to-install-python-3-3

Categories : Python

Python Linux Joystick support?
There is evdev, It's only for Linux, and it seems to be able to do much more than just handling joystick. I've never tried it, though. I spent some time looking for a library to only read joystick in a cross-platform way, but didn't find any, and I've ended up with pygame (only initializing joystick and event modules) in my projects.

Categories : Python

Python threading vs. multiprocessing in Linux
Yes, it is true. Starting a new process (called a heavyweight process) is costly. As an overview ... The OS has to (in the linux case) fork the first process, set up the accounting for the new process, set up the new stack, do the context switch, copy any memory that gets changed, and tear all that down when the new process returns. The thread just allocates a new stack and thread structure, does the context switch, and returns when the work is done. ... that's why we use threads.

Categories : Python

os.system vs subprocess in python on linux
You should use subprocess. Not that it makes any difference, it's just newer module intended to replace os.system (have a look at this section for a drop-in replacement). It also has more features in case you need them one day. In short: there is no reason to use os.system (except for compatibility with older versions of Python).

Categories : Python

Input not read in Python for Linux
You've deliberately chosen a getch implementation that avoids queueing and only grabs the latest character. You can service input faster by moving the # Do Something # part to a background thread, or use an event-loop-like implementation where you queue up all available characters before trying to process the first one off the queue, etc. But none of that will guarantee you get all characters. If you want to allow characters to queue up to make sure you don't miss any, just… don't use an implementation that's designed not to let them queue up. If you don't need getch to timeout after 2 seconds, you can just do this by just not calling select. That also means you don't need TCSADRAIN. Also, instead of calling setraw, try turning off just the flags you care about. Disabling ICANON is

Categories : Python

Using python to substitute awk for Linux commands
You probably want to look at the datetime.datetime.strftime() function for that particular task. However, for the more general task of printing out certain fields, you'd use .split() and list slicing: date_string = "Mon Jun 24 01:30:08 EDT 2013" fields = date_string.split() print ' '.join(fields[1:5]) # Prints "June 24 01:30:08 EDT"

Categories : Python

How to disable cookie handling with the Python requests library?
You're getting back "k2": "v2", "k1": "v1" because they're sent in GET params. If you follow up with a second request you'll see you send no cookies. Unless you use requests.Session cookies are not automatically handled in the client and you have to explicitly pass a dict or CookieJar with each request. In [17]: r = requests.get("http://httpbin.org/cookies/set?k1=v1&k2=v2") In [18]: r.content Out[18]: '{ "cookies": { "k2": "v2", "k1": "v1" } }' In [20]: r.cookies.get_dict() Out[20]: {} In [21]: r = requests.get("http://httpbin.org/cookies") In [22]: r.content Out[22]: '{ "cookies": {} }'

Categories : Python

Run excel macro from python (Windows and Linux)
You would almost certainly be better off adding your formatting and doing other operations in python then saving as an Excel xml file. Since AFAIK Excel is only available for Windows and Mac you are going to be out of luck trying anything like this on Linux. Why not do something similar for Open Office or Libra Office? There is also pySpread which will really whet your appetite.

Categories : Python

Python : rcvfrom() doesn't work in Linux
Typically, on Linux when you've iptables (IPv4 packet filtering and NAT-ing tools, by configuring it you can drop or accept packets on Linux) enabled the default configuration drops the UDP packets. To fix the issue do the followings: iptables -F all What it does is, flush all the iptables which allows udp packets but remember on production systems don't do it with "iptables -F all" (it flushes all the chains available), instead find out the chain which causes to drop the packet and fix that chain.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.