Some problem in code execution in python

2021-01-07 Thread Dario Dario
Sir, I am one of the user of your python program, that is after completion
of installation I got some statement like "you got code execution problem
". I don't know how to rectify this problem.so please help me to rectify
this problem .
You send me the solution in this email ID itself .
-- 
https://mail.python.org/mailman/listinfo/python-list


question from beginner

2005-09-07 Thread dario
Hi, Im new on phyton programming.
On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive
a string from serial port and after send this one enclosed in an
e-mail.
All OK if the string is directly generated in the code. But it doesn't
works if I wait for this inside a 'while' loop. This is the simple
code:

global stringZVEI

  while stringZVEI=='':
  MOD.sleep(10)
  a=SER.send(' sono nel while stringZVEI==st vuota')
  stringZVEI = SER.readbyte()
  a=SER.send(' stringZVEI=')
  a=SER.send(stringZVEI)

MOD and SER are embedded class maked by third part.

>From my very little debug possibility it seem that loop is executed 1
time only nevertheless stringZVEI is still empty. The line
  a=SER.send(' stringZVEI=')
work correctly but

a=SER.send(stringZVEI) 

doesn't work

Any suggestion?

Thanks
Dario.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question from beginner

2005-09-08 Thread dario
Thanks Dennis. In effect stringZVEI doesn't remain empty after the
.read method, then the loop is executed 1 time.

How could be a 'while' loop to wait a no empty string from the serial
port?

Dario.

Dennis Lee Bieber ha scritto:

> On 7 Sep 2005 07:14:37 -0700, "dario" <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
> > Hi, Im new on phyton programming.
> > On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive
> > a string from serial port and after send this one enclosed in an
> > e-mail.
> > All OK if the string is directly generated in the code. But it doesn't
> > works if I wait for this inside a 'while' loop. This is the simple
> > code:
> >
>   First -- post the real code file would help -- the indentation of
> the first two statements below is wrong.
>
> > global stringZVEI
> >
>   This does nothing at the top level -- if only makes sense INSIDE a
> "def" block, where it has the effect of saying "this variable is not
> local to the function"
>
> >   while stringZVEI=='':
> >   MOD.sleep(10)
>
>   There is something wrong with
>
>   import time
>   time.sleep()
> 
>
> >   a=SER.send(' sono nel while stringZVEI==st vuota')
> >   stringZVEI = SER.readbyte()
>
>   #for debug
>   print "%2X " % stringZVEI
>
> >   a=SER.send(' stringZVEI=')
> >   a=SER.send(stringZVEI)
> >
> > MOD and SER are embedded class maked by third part.
> >
> > >From my very little debug possibility it seem that loop is executed 1
> > time only nevertheless stringZVEI is still empty. The line
> >   a=SER.send(' stringZVEI=')
> > work correctly but
> >
> > a=SER.send(stringZVEI)
> >
>   What does .readbyte() do if there is no data to be read? Since your
> loop is based on a totally empty string, if .readbyte returns /anything/
> (even a "null" byte -- 0x00) your loop will exit; and a null byte may
> not be visible on the send...
>
> --
>  > == <
>  >   [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >  [EMAIL PROTECTED] |   Bestiaria Support Staff   <
>  > == <
>  >   Home Page: <http://www.dm.net/~wulfraed/><
>  >Overflow Page: <http://wlfraed.home.netcom.com/><

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question from beginner

2005-09-09 Thread dario
e:
read = ''
return read

def write(self, s):
"""write string to serial port"""
if not self.hComPort: raise portNotOpenError
#print repr(s),
if s:
err, n = win32file.WriteFile(self.hComPort, s,
self._overlappedWrite)
if err: #will be ERROR_IO_PENDING:
# Wait for the write to complete.

win32event.WaitForSingleObject(self._overlappedWrite.hEvent,
win32event.INFINITE)

def flushInput(self):
if not self.hComPort: raise portNotOpenError
win32file.PurgeComm(self.hComPort, win32file.PURGE_RXCLEAR |
win32file.PURGE_RXABORT)

def flushOutput(self):
if not self.hComPort: raise portNotOpenError
win32file.PurgeComm(self.hComPort, win32file.PURGE_TXCLEAR |
win32file.PURGE_TXABORT)

def sendBreak(self):
if not self.hComPort: raise portNotOpenError
import time
win32file.SetCommBreak(self.hComPort)
#TODO: how to set the correct duration??
time.sleep(0.020)
win32file.ClearCommBreak(self.hComPort)

def setRTS(self,level=1):
"""set terminal status line"""
if not self.hComPort: raise portNotOpenError
if level:
win32file.EscapeCommFunction(self.hComPort,
win32file.SETRTS)
else:
win32file.EscapeCommFunction(self.hComPort,
win32file.CLRRTS)

def setDTR(self,level=1):
"""set terminal status line"""
if not self.hComPort: raise portNotOpenError
if level:
win32file.EscapeCommFunction(self.hComPort,
win32file.SETDTR)
else:
win32file.EscapeCommFunction(self.hComPort,
win32file.CLRDTR)

def getCTS(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_CTS_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

def getDSR(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_DSR_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

def getRI(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_RING_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

def getCD(self):
"""read terminal status line"""
if not self.hComPort: raise portNotOpenError
return MS_RLSD_ON & win32file.GetCommModemStatus(self.hComPort)
!= 0

#Nur Testfunktion!!
if __name__ == '__main__':
print __name__
s = Serial(0)



About second question I have to read a string of data from the modem
serial port but I was using .readbyte to semplify the code. In effect
.readbyte doesn't return a string type. I repeat the test with .read
method but I discovered another strange behaviour. If the string is not
'sended' to a DTE (serial not connected ot other) the .read method read
the string(s) still not 'sent'. In other words it seems that the rx and
tx serial buffer are shared.

Thanks for your time.
Dario.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to upgrade to 2.4.1 on Mac OS X tiger

2005-09-13 Thread dario
Hi Dennis, unfortunately I can only use SER class and not 'serial'
class.
This because my emebedded phyton version don't show any import
possibility to this class. It run on the Trizium modem.
Serial I attached above, was coming from the 'simulator' code installed
on my PC.
How I can simulate your code without serial class?  It is better with
SER.read()  than SER.readbyte() because I have to read a string.

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


pySerial works in miniterm but not in my app

2014-10-30 Thread Dario
Python 2.7.6 on Mint, pySerial 2.6

I'm trying to write a console app to control a certain device via a usb com 
port.

In miniterm (-p /dev/ttyUSB0 -e -b 19200), I can communicate correctly with 
this configuration:

--- Settings: /dev/ttyUSB0  19200,8,N,1
--- RTS: inactive  DTR: inactive  BREAK: inactive
--- CTS: inactive  DSR: inactive  RI: inactive  CD: inactive
--- software flow control: inactive
--- hardware flow control: inactive
--- data escaping: raw  linefeed: CR

sw o01 + <--- I send this
sw o01 + Command OK <--- device does what it should *and* I receive this


Now my code:


import serial

s = serial.serial_for_url(
'/dev/ttyUSB0',
19200,
bytesize = 8,
parity   = 'N',
stopbits = 1,
rtscts   = False,
dsrdtr   = False,
xonxoff  = False,
timeout  = 1 # tried without
)
s.close() # tried without
s.open()
s.write('sw o01 +\r')
s.flush() # tried without
s.close() # tried with a sleep before close


With this I don't receive anything (tried with readline etc, omitted for 
readability), and the device doesn't react. Also, if I connect again with 
miniterm and issue the command, I first receive a "wrong command" message, as 
if some garbage was actually sent by my app, then it works again.

Isn't my config equivalent to the one in miniterm? Anything missing?

Thanks

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-10-31 Thread Dario
Il giorno giovedì 30 ottobre 2014 23:57:40 UTC+1, Dennis Lee Bieber ha scritto:

> >sw o01 + <--- I send this

> How do you "send this"... 

I just type or paste it in miniterm and hit return. Miniterm sends the return 
as CR, but it also works with CRLF.

> >sw o01 + Command OK <--- device does what it should *and* I receive this

> Is that a new line, or somehow part of the same line?

This is the response from the device, saying that my command was ok, and it 
also does what it should (it's an hdmi 4-4 matrix, it switches the first output 
to the next input).

> >s.write('sw o01 +\r')

> What happens if you use \n... or \r\n ?

In my app, that doesn't make any difference, never works. In miniterm, only CR 
and CRLF work, LF alone does not.

This evening I'll try with com0com to see what is really sent...

-- 
Dario
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-11-01 Thread Dario
Il giorno venerdì 31 ottobre 2014 19:00:26 UTC+1, Dennis Lee Bieber ha scritto:

> Didn't quite answer my question. If the comm line is using remote 

I understand your point, I didn't mention but I also tried sending one char at 
a time and listening at the same time, nothing changed.

BUT.. plot twist: in Windows XP, the very same python code and usb adapter are 
working just right (python 2.7 and pySerial 2.7). Also with c#, no issues.

So one could blame the usb adapter or its drivers, but the fact is that minicom 
(not miniterm) always works, while miniterm only works if used after minicom, 
and only the first time.

I mean: I start minicom, it works. Close it (quit without reset), start 
miniterm, it works. Close miniterm, open it again, just garbage...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-11-01 Thread Dario
Il giorno sabato 1 novembre 2014 16:04:06 UTC+1, Dario ha scritto:

> BUT.. plot twist: in Windows XP, the very same python code and usb adapter 
> are working just right (python 2.7 and pySerial 2.7). Also with c#, no issues.

I compared the behaviour of mono and python (2.7 and 3.3) on the same hw and 
os, I guess something is wrong with pySerial implementation...

Mono code on Mint:


SerialPort s = new SerialPort("/dev/ttyUSB0", 19200, Parity.None, 8, 
StopBits.One);
s.Open();

s.Write("sw o01 +\r");

while (true)
Console.Write(Convert.ToChar(s.ReadByte()));


Device reacts correctly and I get back what I expect (the first line is because 
I sent the command via com port, the second is because I pushed a button on the 
device):

dario@ivymint ~ $ sudo ./Test1.exe 
sw o01 + Command OK
Button 1 pushed


Now equivalent Python 3.3 code on Mint:

---
import serial

s = serial.serial_for_url('/dev/ttyUSB0', 19200, bytesize = 8, parity = 'N', 
stopbits = 1)

s.close()
s.open()
s.write(bytearray('sw o01 +\r','ascii'))

while True:
print(s.read())
---

In this case, I don't receive anything for my command, and when I press I 
receive garbage instead of "Button 1 pushed"

dario@ivymint ~ $ sudo python3 ./test2.py 
b'\xfc'
b'\x8f'
b'\r'
b'\x85'
b'1'
b'+'
b'\xfe'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pySerial works in miniterm but not in my app

2014-11-01 Thread Dario
Ehm sorry for the neverending spam, anyway I tried from my raspberry pi and it 
works there:

root@pi:/home/pi# python3 ./test.py 
b's'
b'w'
b' '
b'o'
b'0'
b'1'
b' '
b'+'
b' '
b'C'
b'o'
b'm'
b'm'
b'a'
b'n'
b'd'
b' '
b'O'
b'K'
b'\r'
b'\n'

Since I need it to work on the rpi and I was using Mint only for easiness, I'm 
ok with it :)

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Image Library IOError - cannot find JPEG decoder?

2009-02-24 Thread Dario Traverso
I've been trying to install the Python Image Library  (PIL) on my Mac  
OSX Leopard laptop, but have been running into some difficulties.


I've built the library, using the included setup.py  script. The build  
summary checks out ok, and sounds the option libraries to all be  
found. I grabbed both libjpeg and freetype2  using  fink.



PIL 1.1.6 BUILD SUMMARY

version   1.1.6
platform  darwin 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
 [GCC 4.0.1 (Apple Inc. build 5465)]

--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok


However,  I then run the included self test, and 1 out of 57 tests  
fails. I receive an IOError. Specifically:


*
Failure in example: _info(Image.open("Images/lena.jpg"))
from line #24 of selftest.testimage
Exception raised:
Traceback (most recent call last):
 File "./doctest.py", line 499, in _run_examples_inner
   exec compile(source, "", "single") in globs
 File "", line 1, in 
 File "./selftest.py", line 22, in _info
   im.load()
 File "PIL/ImageFile.py", line 180, in load
   d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
 File "PIL/Image.py", line 375, in _getdecoder
   raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
1 items had failures:
  1 of  57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.


I've followed all of the installation instructions exactly. The build  
summary reported everything was "ok". What could be the problem here.   
Libjpeg-6b  is not accessible?


Thank you for any insight you can provide!!

-Dario
--
http://mail.python.org/mailman/listinfo/python-list


SFTP: max bytes to be transferred

2010-12-01 Thread Dario Beraldi

Hello,

I'm using the module paramiko to transfer files via sftp (see code below).
I would like to specify the maximum amount of bytes to be transferred  
(say 10MB, if the file is bigger just transfer up to these many bytes).


From the docs of paramiko  
(http://www.lag.net/paramiko/docs/paramiko.SFTPClient-class.html#get)  
I see that the method get() can take an optional callback parameter  
which is a "function that accepts the bytes transferred so far and the  
total bytes to be transferred". This seems to do what I need but I  
don't know how to specify such callback function. Any idea?


This is my code:
[ Cut here ]-

import paramiko
host = "my.host"
port = 22
transport = paramiko.Transport((host, port))

password = "mypassword"
username = "myname"
transport.connect(username = username, password = password)

sftp = paramiko.SFTPClient.from_transport(transport)

filepath = 'file/to/myfile.txt'
localpath = 'D:/Tritume/myfile.txt'

sftp.get(filepath, localpath) ## <-- Calback function should go here

[ cut here]---

Many thanks
Dario



--

Dr. Dario Beraldi
Institute of Evolutionary Biology
University of Edinburgh
West Mains Road
Edinburgh EH9 3JT
Scotland, UK


--

Dr. Dario Beraldi
Institute of Evolutionary Biology
University of Edinburgh
West Mains Road
Edinburgh EH9 3JT
Scotland, UK


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


--
http://mail.python.org/mailman/listinfo/python-list