Hi,
I am trying to send a character to '/dev/ttyS0' and expect the same
character and upon receipt I want to send another character. I tired
with Pyserial but in vain.
Test Set up:
1. Send '%' to serial port and make sure it reached the serial port.
2. Once confirmed, send another character.
I tried with write and read methods in Pyserial but no luck.
Can you help?
Thanking you all.
T 6 6503
En Fri, 25 Apr 2008 20:22:37 -0300, terry <it*********@gmail.comescribió:
I am trying to send a character to '/dev/ttyS0' and expect the same
character and upon receipt I want to send another character. I tired
with Pyserial but in vain.
I assume you have a device attached to /dev/ttyS0 that echoes back the
received characters?
Test Set up:
1. Send '%' to serial port and make sure it reached the serial port.
2. Once confirmed, send another character.
I tried with write and read methods in Pyserial but no luck.
Check the communication parameters (baud rate, parity, etc.), cable,
connectors, your device... AFAIK a lot of people is using pyserial so I'd
look the problem elsewhere. Try posting a short code example showing your
problem.
--
Gabriel Genellina
terry wrote:
I am trying to send a character to '/dev/ttyS0' and expect the
same character and upon receipt I want to send another character.
I tired with Pyserial but in vain.
Pyserial works very well for me (despite the device I connect to has
quite a screwed protocol and implementation).
Test Set up:
1. Send '%' to serial port and make sure it reached the serial
port. 2. Once confirmed, send another character.
I tried with write and read methods in Pyserial but no luck.
Are you actaully trying to get lucky by doing this, or are you
observing a specific problem, e.g. nothing is received or wrong
characters are received? Also, by what are they received?
Regards,
Björn
--
BOFH excuse #139:
UBNC (user brain not connected)
On 2008-04-25, terry <it*********@gmail.comwrote:
I am trying to send a character to '/dev/ttyS0' and expect the
same character and upon receipt I want to send another
character. I tired with Pyserial but in vain.
Pyserial works. I've been using it almost daily for many
years. Either your program is broken, your serial port is
broken, or the device connected to the serial port is broken.
Test Set up:
1. Send '%' to serial port and make sure it reached the serial port.
2. Once confirmed, send another character.
I tried with write and read methods in Pyserial but no luck.
Can you help?
Ah yes, the problem is in line 89 of your program.
We've no way to help if you don't provide details. If you
really want help, write as small a program as possible that
exhibits the problem. I'd like to emphasize _small_. The
larger the program the less likely people are to look at it,
and the less likely they are to find the problem if they do
look at it.
Much of the time the exercise of writing a small demo program
will lead you to the answer. If not, then post it, along with
the output from the program that shows the problem.
Then we can tell you what you did wrong.
--
Grant Edwards grante Yow! I'm also against
at BODY-SURFING!!
visi.com
On Apr 26, 8:21*am, Grant Edwards <gra...@visi.comwrote:
On 2008-04-25, terry <itskrith...@gmail.comwrote:
I am trying to send a character to '/dev/ttyS0' and expect the
same character and upon receipt I want to send another
character. I tired withPyserialbut in vain.
Pyserialworks. *I've been using it almost daily for many
years. *Either your program is broken, your serial port is
broken, or the device connected to the serial port is broken.
Test Set up:
1. Send '%' to serial port and make sure it reached the serial port.
2. Once confirmed, send another character.
I tried with write and read methods inPyserialbut no luck.
Can you help?
Ah yes, the problem is in line 89 of your program.
We've no way to help if you don't provide details. If you
really want help, write as small a program as possible that
exhibits the problem. *I'd like to emphasize _small_. The
larger the program the less likely people are to look at it,
and the less likely they are to find the problem if they do
look at it.
Much of the time the exercise of writing a small demo program
will lead you to the answer. *If not, then post it, along with
the output from the program that shows the problem.
Then we can tell you what you did wrong.
--
Grant Edwards * * * * * * * * * grante * * * * * * Yow! I'm also against
* * * * * * * * * * * * * * * * * at ** * * * * * BODY-SURFING!!
* * * * * * * * * * * * * * * *visi.com * * * * * *
Here is the code.
"""Open serial connection"""
def openSerialConnection(self,serpt):
try:
s1 = serial.Serial(serpt,timeout=10)
except:
self.print_u("Failed to open serial port %s. " %serpt)
def enterThroughSerialPort(self,serpt):
s1 = serial.Serial(serpt,timeout=10)
self.print_u('Sending !!!!..')
while True:
s1.write('*')
c = s1.read(1)
if c:
self.print_u('Found "*" ')
break
print c
s1.write('enter\r')
s1.read('login')
if __name__ == '__main__':
serpt = '/dev/ttyS0'
x.openSerialConnection(serpt)
# funtion to reboot the device goes here ---#
x.enterThroughSerialPort(serpt)
After opening the serial connection, the device is rebooted followed
by sending '*' to serial port and reading back the same. I seem to
have problem while trying to read '*' back from serial port. First of
all I am not sure if serial port received the '*'.
Thanks!
On May 2, 10:26*am, terry <itskrith...@gmail.comwrote:
On Apr 26, 8:21*am, Grant Edwards <gra...@visi.comwrote:
On 2008-04-25, terry <itskrith...@gmail.comwrote:
I am trying to send a character to '/dev/ttyS0' and expect the
same character and upon receipt I want to send another
character. I tired withPyserialbut in vain.
Pyserialworks. *I've been using it almost daily for many
years. *Either your program is broken, your serial port is
broken, or the device connected to the serial port is broken.
Test Set up:
1. Send '%' to serial port and make sure it reached the serial port.
2. Once confirmed, send another character.
I tried with write and read methods inPyserialbut no luck.
Can you help?
Ah yes, the problem is in line 89 of your program.
We've no way to help if you don't provide details. If you
really want help, write as small a program as possible that
exhibits the problem. *I'd like to emphasize _small_. The
larger the program the less likely people are to look at it,
and the less likely they are to find the problem if they do
look at it.
Much of the time the exercise of writing a small demo program
will lead you to the answer. *If not, then post it, along with
the output from the program that shows the problem.
Then we can tell you what you did wrong.
--
Grant Edwards * * * * * * * * * grante * * * ** * Yow! I'm also against
* * * * * * * * * * * * * * * * * at * * * * * * * BODY-SURFING!!
* * * * * * * * * * * * * * * *visi.com * * * * * *
Here is the code.
"""Open serial connection"""
* * * * def openSerialConnection(self,serpt):
* * * * * * try:
* * * * * * * * s1 = serial.Serial(serpt,timeout=10)
* * * * * * except:
* * * * * * * * self.print_u("Failed to open serial port %s. " %serpt)
* * * * def enterThroughSerialPort(self,serpt):
* * * * * * s1 = serial.Serial(serpt,timeout=10)
* * * * * * *self.print_u('Sending !!!!..')
* * * * * * *while True:
* * * * * * * * s1.write('*')
* * * * * * * *c = s1.read(1)
* * * * * * * *if c:
* * * * * * * * * self.print_u('Found "*" ')
* * * * * * * * * * break
* * * * * * print c
* * * * * * *s1.write('enter\r')
* * * * * * *s1.read('login')
if __name__ == '__main__':
* * serpt = '/dev/ttyS0'
* * x.openSerialConnection(serpt)
* * # funtion to reboot the device goes here ---#
* * x.enterThroughSerialPort(serpt)
After opening the serial connection, the device is rebooted followed
by sending '*' to serial port and reading back the same. I seem to
have problem while trying to read '*' back from serial port. First of
all I am not sure if serial port received the '*'.
Thanks!- Hide quoted text -
- Show quoted text -
This is the err message I received:
c = s1.read(1)
File "/usr/local/lib/python2.5/site-packages/serial/serialposix.py",
line 275, in read
ready,_,_ = select.select([self.fd],[],[], self._timeout)
En Fri, 02 May 2008 15:44:09 -0300, terry <it*********@gmail.comescribió:
On May 2, 10:26*am, terry <itskrith...@gmail.comwrote:
>On Apr 26, 8:21*am, Grant Edwards <gra...@visi.comwrote:
Much of the time the exercise of writing a small demo program
will lead you to the answer. *If not, then post it, along with
the output from the program that shows the problem.
Here is the code.
"""Open serial connection""" * * * * def openSerialConnection(self,serpt): * * * * * * try: * * * * * * * * s1 = serial.Serial(serpt,timeout=10)
* * * * * * except: * * * * * * * * self.print_u("Failed to open serial port %s. " %serpt)
* * * * def enterThroughSerialPort(self,serpt): * * * * * * s1 = serial.Serial(serpt,timeout=10) * * * * * * *self.print_u('Sending !!!!..') * * * * * * *while True: * * * * * * * * s1.write('*') * * * * * * * *c = s1.read(1) * * * * * * * *if c: * * * * * * * * * self.print_u('Found "*" ') * * * * * * * * * * break * * * * * * print c * * * * * * *s1.write('enter\r') * * * * * * *s1.read('login')
if __name__ == '__main__': * * serpt = '/dev/ttyS0' * * x.openSerialConnection(serpt) * * # funtion to reboot the device goes here ---# * * x.enterThroughSerialPort(serpt)
After opening the serial connection, the device is rebooted followed by sending '*' to serial port and reading back the same. I seem to have problem while trying to read '*' back from serial port. First of all I am not sure if serial port received the '*'.
This is the err message I received:
c = s1.read(1)
File "/usr/local/lib/python2.5/site-packages/serial/serialposix.py",
line 275, in read
ready,_,_ = select.select([self.fd],[],[], self._timeout)
If you want some help, you have to help us to diagnose the problem.
The above lines are just a small excerpt of the complete error report that
surely you got; usually it includes the exception *type*, the exception
*value*, and the whole *stack trace*. Now we have to *guess* what happened
in that select call.
Also, when posting code, try to post the *actual* code you run - copy and
paste it. Do not retype it again. The code you posted has indentation
errors, uninitialized variables...
Try to make a *small*, runnable example that reproduces the problem;
remove anything that isn't esential to the issue being discussed. Write
down what is your expected behaviour, and what actually happens. If the
program halts due to an error, copy the *whole* report including the
exception type, message, and the complete traceback.
In this particular case, due to the serial device, it's improbable that
someone will be able to execute your program, but anyway try to write the
example code. Sometimes you may find the problem yourself just by trying
to write the example.
A few notes on the code:
- don't create many Serial objects; create only a single instance and use
it everywhere it is needed. (That is, instead of using '/dev/ttyS0' as an
argument, pass the Serial object already created, or save it as an
instance attribute: self.serial = Serial(...) )
- ensure you're using the right protocol parameters (baud rate, bits,
parity...) for the device. That's why it helps to create the Serial object
in a single place.
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bob Greschke |
last post by:
We have some equipment that communicates at 57600 baud RS232. The path from
the PC is USB to a Phillips USB hub, then off of that a TUSB3410 USB/Serial
converter. The driver for the 3410 chip...
|
by: googlinggoogler |
last post by:
Hiya,
I've got a PIC microcontroller reading me humidity data via rs232, this
is in ASCII format. I can view this data easily using hyperterminal or
pyserial and convert it to its value...
|
by: luca72 |
last post by:
Hello at all
sorry for my english but i'm Italian.
I use pyserial to communicate via rs232 with an extarnal device called
smartmouse.
I write the exact line that i want , but when i read i read...
|
by: Alejandro |
last post by:
Hi:
I'm using pySerial to talk to a RS232 to RS485 converter. In order to
control the converter, I need to control the DTR line to enable/disable
de RS485 driver. In particular, I need to :
...
|
by: alexandre_irrthum |
last post by:
Hi there,
I am trying to use pyserial to read data from a temperature logger
device (T-logger). T-logger is based on the DS1615 temperature recorder
chip (Dallas Semiconductor). According to the...
|
by: [david] |
last post by:
http://pyserial.sourceforge.net/
"port numbering starts at zero, no need to
know the port name in the user program"
But the implementation in SerialWin32 is
just
(Portnum +1)
|
by: naveen.sabapathy |
last post by:
Hi,
I am trying to use virtual serial ports to develop/test my serial
communication program. Running in to trouble...
I am using com0com to create the virtual ports. The virtual ports
seem to...
|
by: Kineta |
last post by:
Hello all,
I am attempting to send commands to the firmware on my PIC18F4550 (usb port) microcontroller using Pyserial. If I open Hyperterminal, I can send the following commands and it works...
|
by: rfarley |
last post by:
Hi,
I am using the pyserial module and am trying to read the serial port from an accelerometer (LIS302DL).
It has an option in which you write "*debug\r\n" and then you read the data (three...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
|
by: DizelArs |
last post by:
Hi all)
Faced with a problem, element.click() event doesn't work in Safari browser.
Tried various tricks like emulating touch event through a function:
let clickEvent = new Event('click', {...
|
by: F22F35 |
last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...
| |