Author Topic: Cannot send string via ser.write() on linux box  (Read 3857 times)

0 Members and 1 Guest are viewing this topic.

cbohart

Cannot send string via ser.write() on linux box
« on: June 25, 2011, 08:13:38 PM »
Here is my problem anyway.

I have boards taking temperature readings and sending them to serial at short intervals.  In eclipse I have written python w/ gui's to receive those readings and do some things.  This works fine on Fedora 14 on two different machines.

I have another board that is set to receive a string ( by incremental char ) and flip switches.  This works perfectly when I send the string through the serial monitor in XP.  The yellow serial led lights up momentarily while the info transfers.  But from the py script on the fedora box - nothing goes.  The blue led blinks once and the yellow led does nada.  I am certain that text encoding is not in play here.  Worse...  the string has in fact gone through occasionally.  After messing with the code it suddenly works and keeps working and then stops.

Here is what I'm using to configure the serial port: 

#! /usr/bin/python2.7
import serial
from Tkinter import*
import time

   
root = Tk()
root.geometry("400x300")

main = Frame(root)   
main.pack()


def sendOnes():
   
    locations=['/dev/ttyUSB0','/dev/ttyUSB1']


    for device in locations:
        try:
            print "Trying...",device
            ser = serial.Serial(device, 9600, timeout=2)
            break
        except:
            print "Failed to connect on",device
           
    time.sleep( 2 )
    str1 = "#,1,1,1$"
    ser.write( str1 )
    time.sleep(1)

   
def sendOs():
   
    locations=['/dev/ttyUSB0','/dev/ttyUSB1']


    for device in locations:
        try:
            print "Trying...",device
            ser = serial.Serial(device, 9600, timeout=2)
            break
        except:
            print "Failed to connect on",device

    time.sleep( 2 )
    str2 = "#,0,0,0$"
    ser.write( str2 )
    time.sleep(1)

   
button1 = Button(root, text="Send 111", command=sendOnes)
button1.pack(anchor=CENTER)   

button2 = Button(root, text="Send 000", command=sendOs)
button2.pack(anchor=CENTER)

 
root.mainloop()

This gives me a gui with buttons so I can "send" repeatedly while looking at board leds.  I placed the additional time.sleep() just in case the machine(s) are taking a while to open the port.

My suspicion is that the linux system is ignoring the baudrate I specify and holding the USB port at some other speed ( I tried some other speeds to no avail).

If you have experience with this please share it with me as I have googled this topic to death and found nothing of use.


barragan

Re: Cannot send string via ser.write() on linux box
« Reply #1 on: July 28, 2011, 06:45:05 PM »
hi Craig this tutorial might help you with the python issue: http://wiring.org.co/learning/tutorials/blender/index.html

ShannonBrady

Re: Cannot send string via ser.write() on linux box
« Reply #2 on: July 30, 2013, 06:50:51 AM »
Here is my problem anyway.

I have boards taking temperature readings and sending them to serial at short intervals.  In eclipse I have written python w/ gui's to receive those readings and do some things.  This works fine on Fedora 14 on two different machines.

I have another board that is set to receive a string ( by incremental char ) and flip switches.  This works perfectly when I send the string through the serial monitor in XP.  The yellow serial led light up momentarily while the info transfers.  But from the py script on the fedora box - nothing goes.  The blue led blinks once and the yellow led does nada.  I am certain that text encoding is not in play here.  Worse...  the string has in fact gone through occasionally.  After messing with the code it suddenly works and keeps working and then stops.

Here is what I'm using to configure the serial port: 

#! /usr/bin/python2.7
import serial
from Tkinter import*
import time

   
root = Tk()
root.geometry("400x300")

main = Frame(root)   
main.pack()


def sendOnes():
   
    locations=['/dev/ttyUSB0','/dev/ttyUSB1']


    for device in locations:
        try:
            print "Trying...",device
            ser = serial.Serial(device, 9600, timeout=2)
            break
        except:
            print "Failed to connect on",device
           
    time.sleep( 2 )
    str1 = "#,1,1,1$"
    ser.write( str1 )
    time.sleep(1)

   
def sendOs():
   
    locations=['/dev/ttyUSB0','/dev/ttyUSB1']


    for device in locations:
        try:
            print "Trying...",device
            ser = serial.Serial(device, 9600, timeout=2)
            break
        except:
            print "Failed to connect on",device

    time.sleep( 2 )
    str2 = "#,0,0,0$"
    ser.write( str2 )
    time.sleep(1)

   
button1 = Button(root, text="Send 111", command=sendOnes)
button1.pack(anchor=CENTER)   

button2 = Button(root, text="Send 000", command=sendOs)
button2.pack(anchor=CENTER)

 
root.mainloop()

This gives me a gui with buttons so I can "send" repeatedly while looking at board leds.  I placed the additional time.sleep() just in case the machine(s) are taking a while to open the port.

My suspicion is that the linux system is ignoring the baudrate I specify and holding the USB port at some other speed ( I tried some other speeds to no avail).

If you have experience with this please share it with me as I have googled this topic to death and found nothing of use.


Hello were you able to sort out the problem.. I have tying a lot to send string via linux box but not successful yet.. Please help me if you can..
« Last Edit: July 31, 2013, 12:17:31 PM by ShannonBrady »

Danniell32

Download video and MP3 youtube
« Reply #3 on: October 26, 2017, 05:12:29 PM »
<a href="https://xn--pgbg3edz.tv/watch?v=xxZ62tTveeE">تحميل الفيديو و MP3 Thaanaa Serndha Koottam - Sodakku Tamil Song Teaser  Suriya  Anirudh l Vignesh ShivN  </a><br>Watch the official song teaser of #Sodakku from Suriya's  #ThaanaaSerndhaKoottam Song Name - Sodakku  Movie - Thaanaa Serndha KoottamSinger - Anthony </br>
<a href="https://xn--pgbg3edz.tv/watch?v=wWshZEdDoR8">تحميل الفيديو و MP3 தமிழிசைக்கு பதிலடி கொடுத்த விஜய்Mersal Movie ReviewMersal GST IssueTamilisai Sowndharajan  </a><br>தமிழிசைக்கு பதிலடி கொடுத்த விஜய்Mersal Movie ReviewMersal GST IssueTamilisai Sowndharajan Mersal MovieAtleeMersal Vijay Mersal Mersal Gst Issue</br>
<a href="https://xn--pgbg3edz.tv/watch?v=lCwA52KoRcQ">تحميل الفيديو و MP3 Parava Movie Scene  Imran & Shane  Soubin Shahir  Dulquer Salmaan  Anwar Rasheed Entertainment  </a><br>Movie : Parava Story / Director  : Soubin ShahirProducers : Anwar Rasheed, Shyju UnniSet As Your Caller tune _______________________Vodafone Users Dia</br>
<a href="https://xn--pgbg3edz.tv/watch?v=SNtxASfwIXA">تحميل الفيديو و MP3 Juan For All, All For Juan ( October 23, 2017 )  </a><br>Eat BulagaJuan For All, All For JuanOctober 23, 2017******** ******** ******** Thank You For WatchingPlease Like And ShareFor More Eat Bulaga Highligh</br>
<a href="https://xn--pgbg3edz.tv/watch?v=OM3fhvUfmpY">تحميل الفيديو و MP3 Sirasa Junior Superstar Sirasa tv 22nd October 2017  </a><br></br>
<a href="https://xn--pgbg3edz.tv/watch?v=koIxLrMVa7s">تحميل الفيديو و MP3 Dhee 10  18th October 2017 Full Episode  ETV Telugu  </a><br>దక్షణ భారతదేశంలోనే అతిపెద్ద డాన్స్ రియాలిటీ షో...9 సీజన్స్ ముగించుకుని ఇపుడు "ఢీ-10" గా మిమ్మల్ని అలరించడానికి, ఎంటర్ టైన్ మెంట్ ని టన్నుల టన్నుల కొద్</br>
<a href="https://xn--pgbg3edz.tv/watch?v=gYpDbK9xTWs">تحميل الفيديو و MP3 مسلسل الطوفان - الحلقة السادسة - The Flood Episode 06  </a><br>مسلسل الطوفان - الحلقة السادسة - The Flood Episode 06مسلسل الطوفان بطولة ماجد المصري - أيتن عامر - وفاء عامر - فتحي عبد الوهاب - أحمد زاهر - ريهام عبد</br>
<a href="https://xn--pgbg3edz.tv/watch?v=JLv5TmC1ivA">تحميل الفيديو و MP3 دايلر - مدرسة (فيديو كليب حصري)  2017  </a><br>دايلر يعود بفيديو كليب حصري ، يتكلم عن اثار الشهرة على الدراسة وان النجاح الحقيقي يتحقق بالعلم .⊙ شكرا لك على المشاهده , فعّل زر التنبيهات (  ) عشان </br>
<a href="https://xn--pgbg3edz.tv/watch?v=d_RjpSp5uVc">تحميل الفيديو و MP3 مقلب الغرق في المسبح !!  </a><br>لتحميل لعبتنا على الآيفون والآيباد : https://goo.gl/zEddTjلتحميل لعبتنا على الآندرويد : https://goo.gl/gZdWxmسنابشات سعود : https://www.snapchat.com/a</br>
<a href="https://xn--pgbg3edz.tv/watch?v=JsaxeWkPdSE">تحميل الفيديو و MP3 لحظة طرد الرئيس الغانم للوفد الإسرائيلي من قاعة اجتماع اتحاد البرلمان الدولي  </a><br></br>
<a href="https://xn--pgbg3edz.tv/watch?v=NbE4J1I5sF0">تحميل الفيديو و MP3 مشيت فوق 100 ولاعة بالسيارة (شوفوا ايش صار)!!  </a><br>شكرا لك على المشاهده , فعّل زر التنبيهات (  ) عشان توصلك الفيديوهات الجديده على طول! - حـسـابـي فـي سـنـاب شـات : [ Mmbawee ]- حـسـآبـي فـي الإنـسـتـ</br>
<a href="https://xn--pgbg3edz.tv/watch?v=koIxLrMVa7s">تحميل الفيديو و MP3 Dhee 10  18th October 2017 Full Episode  ETV Telugu  </a><br>దక్షణ భారతదేశంలోనే అతిపెద్ద డాన్స్ రియాలిటీ షో...9 సీజన్స్ ముగించుకుని ఇపుడు "ఢీ-10" గా మిమ్మల్ని అలరించడానికి, ఎంటర్ టైన్ మెంట్ ని టన్నుల టన్నుల కొద్</br>
<a href="https://xn--pgbg3edz.tv/watch?v=H1b0yK1_m28">تحميل الفيديو و MP3 الجزيرة في تقرير تفصيلي تكشف بالفيديو كواليس وأسرار ما جرى في الواحات 20.10.2017  </a><br>please like share subscribe من فضلك لايك وشير للفيديو واشترك في قناتيhttps://www.facebook.com/syasaextra تابعوا صفحتنا على الفيسبوكhttps://www.twitter</br>
<a href="https://xn--pgbg3edz.tv/watch?v=7pIzo0QuWJA">تحميل الفيديو و MP3 رحنا للبر وتكلمنا في الجن و صار شي مخيف اعوذ بالله  </a><br>شكراً على المشاهدة :) إذا عجبك المقطع لا تنسى تدعمني بـ"لايك" و "الاشتراك" .كود الخصم: HONOR9http://www.hihonor.com -  مقطعي السابق  مقطع الهجوله ht</br>
<a href="https://xn--pgbg3edz.tv/watch?v=OGrOod2FaKM">تحميل الفيديو و MP3 تعليق أبو تريكة الأسطوري عن فوز الأهلي المصري علي النجم الساحلي 6 - 2 و صعود الاهلي للنهائي 2018  </a><br>الرجاء الإشتراك بالقناة وشكرا لكم .</br>
<a href="https://xn--pgbg3edz.tv/watch?v=nLRBm4n538k">تحميل الفيديو و MP3 عم سعيد و قتل ٦٠ ظابط في الواحات (القصة كاملة)  </a><br></br>
<a href="https://xn--pgbg3edz.tv/watch?v=JYApzdYCQew">تحميل الفيديو و MP3 Savitri Latest Telugu Full Movie  Nara Rohit, Nanditha   2017 Telugu Movies  </a><br>Savitri Latest Telugu Full MovieMovie: Savitri,Starring: Nara Rohit, Nanditha,Director: Pavan Sadineni,Music: ShravanProducer: Dr. V.B. Rajendra Prasa</br>
<a href="https://xn--pgbg3edz.tv/watch?v=HcUN8L48L6s">تحميل الفيديو و MP3 ETV Pandaga Chesko  Diwali Special Event  19th October 2017  ETV Telugu  </a><br>☛ For latest updates on ETV Channels  http://www.etv.co.in   ☛ Subscribe for more latest Episodes  http://bit.ly/12A56lY ☛ Like us on  http://www.f</br>
<a href="https://xn--pgbg3edz.tv/watch?v=5UPi6hMidLo">تحميل الفيديو و MP3 Extra Jabardasth  20th October 2017  Full Episode  ETV Telugu  </a><br>A comedy show, in which comedians like Sudigaali Sudheer, Chammak Chandra and Hyper Aadi perform sidesplitting comedy skits. ☛ For latest updates on </br>
<a href="https://xn--pgbg3edz.tv/watch?v=H9770lB6E2M">تحميل الفيديو و MP3 Baahubali 2 - The Conclusion Telugu Full Movie  4K Ultra HD with Subtitles  </a><br>Watch Baahubali 2 Full Movie.Baahubali 2 - The Conclusion is part a two part Indian movie, directed by S.S. Rajamouli. The film released in Telugu, Ta</br>
 

Danniell32

Download video and MP3 youtube
« Reply #4 on: October 26, 2017, 05:13:02 PM »
<a href="https://descargarvideosdeyoutube.top/watch?v=CpD885lO0DM">Descargar VÍDEO o MP3 7 Objetos de las Caricaturas que Existen en la Vida Real</a><br>Todos hemos soñado alguna vez con tener alguno de los objetos de nuestras caricaturas favoritas en l</br>
<a href="https://descargarvideosdeyoutube.top/watch?v=wTsI55Z3JUk">Descargar VÍDEO o MP3 MÁS MITOS BIOLÓGICOS</a><br>¿Se puede donar sangre si tienes un tatuaje? ¿Realmente fuiste el espermatozoide más rápido en una c</br>
<a href="https://descargarvideosdeyoutube.top/watch?v=RjWtjUd5nT0">Descargar VÍDEO o MP3 El Señor de los cielos 5 - capítulo 88 5/7 suscribirte si quieres que suba más CPS.</a><br></br>
<a href="https://descargarvideosdeyoutube.top/watch?v=fMVGfxoCkfU">Descargar VÍDEO o MP3 Avance del Capitulo 57 - Dragon Ball Super audio latino</a><br></br>
<a href="https://descargarvideosdeyoutube.top/watch?v=zUnVw7dsPDc">Descargar VÍDEO o MP3 Ana Gabriel, Rocío Dúrcal, Amanda Miguel, Marisela Y Jenni Rivera EXITOS mix sus mejores canciones</a><br>Ana Gabriel, Rocío Dúrcal, Amanda Miguel, Marisela Y Jenni Rivera EXITOS mix sus mejores canciones</br>
<a href="https://descargarvideosdeyoutube.top/watch?v=Sl_HkYrSnV4">Descargar VÍDEO o MP3 ¿POR QUÉ NO GANÓ MESSI "THE BEST"?  CRISTIANO:"QUIERO 7 MÁS"  PREGUNTAN A NEYMAR POR EL BARÇA</a><br>¿POR QUÉ NO GANÓ MESSI EL PREMIO "THE BEST?CRISTIANO DICE QUE QUIERE 7 MÁS!¿QUE PASÓ CON NEYMAR Y EL</br>
<a href="https://descargarvideosdeyoutube.top/watch?v=Who_JoZfmJ0">Descargar VÍDEO o MP3 Conoce al nuevo meserito</a><br>Nos puedes seguir en Twitter @multimediostvhttps://www.facebook.com/multimediostvPara mas informació</br>
<a href="https://descargarvideosdeyoutube.top/watch?v=VDjo7Xp7_L0">Descargar VÍDEO o MP3 Luis Miguel- "Canción Nueva" (Adelanto)</a><br>Adelanto del nuevo material de Luis Miguel, proximamente</br>
<a href="https://descargar.one/watch?v=F75CibembZk">Descargar VÍDEO o MP3 Love Beats Hate (Subtítulos en español)</a><br>¿Qué está pasando en España? ¿Qué sucede con Cataluña? se pregunta la protagonista del corto. La jov</br>
<a href="https://descargar.one/watch?v=8zv4EHGXawA">Descargar VÍDEO o MP3 VUELVO A MI ANTIGUO TRABAJO</a><br>TWEET PARA HACER RT: https://goo.gl/GBsR9UCOMPRA EL LIBRO AQUÍ: https://goo.gl/pfKn1FY AQUÍ TAMBIÉN:</br>
<a href="https://descargar.one/watch?v=mpXcM61rmuI">Descargar VÍDEO o MP3 Leticia Sabater llega al Upside Down  Stranger Things  Netflix</a><br>En Hawkins están pasando cosas raras... y Leticia Sabater aún no lo sabe. Stranger Things 2 llega el</br>
<a href="https://descargar.one/watch?v=ieCXrfX7hOk">Descargar VÍDEO o MP3 LAS 8 PEORES COMPRAS POR INTERNET</a><br>El Vídeo que Cambió Vidas: https://goo.gl/Jo4hsfCompras fails por Internet supuestamente ¿Vale? ¡Dam</br>
<a href="https://descargar.one/watch?v=S1psgZVuBIc">Descargar VÍDEO o MP3 Magnífica respuesta de Toni Cantó a Guardiola</a><br>Magnífica respuesta de Toni Cantó a Guardiola, un ejemplo de adoctrinado del independentismo que tie</br>
<a href="https://descargar.one/watch?v=x7T0u3Wt3Tw">Descargar VÍDEO o MP3 JAVIER NART HUMILLA A LOS CATALANISTAS RADICALES independentistas referendum cataluña puigdemont</a><br>JAVIER NART HUMILLA A LOS CATALANISTAS RADICALES independentistas referendum cataluña puigdemont</br>
<a href="https://descargar.one/watch?v=dhnk7tPWIGA">Descargar VÍDEO o MP3 GUSANOS COMESTIBLES de gelatina</a><br>CÓMO HACER GUSANOS COMESTIBLES  Como se aproxima HALLOWEEN hemos decidido enseñaros a hacer una rec</br>
<a href="https://descargar.one/watch?v=n-MZZz9Of5g">Descargar VÍDEO o MP3 La inesperada sorpresa de la reina Letizia en Poreñu: su abuela, Menchu Álvarez del Valle</a><br></br>
<a href="https://descargar.one/watch?v=eRwONH4LzsU">Descargar VÍDEO o MP3 EL MEJOR TAG DEL TRAP CON MIS HERMANAS NEUS SNOW</a><br>PERSONAS HOY OS TRAIGO EL TAG DEL TRAP CON MIS DOS HERMANAS!! ¿QUIEN CREEIS QUE BAILA MEJOR? JAJAJAJ</br>
<a href="https://descargar.one/watch?v=BQ0mxQXmLsk">Descargar VÍDEO o MP3 Camila Cabello - Havana ft. Young Thug</a><br>"Havana" Available at Spotify: http://smarturl.it/Havana_Sptfy Apple Music: http://smarturl.it/Havan</br>
<a href="https://descargar.one/watch?v=YicomoMhMAM">Descargar VÍDEO o MP3 LATE MOTIV - David Broncano. "Pachacho herido"  #LateMotiv290</a><br>El rey del putoamismo elegante se ha roto un huechito. ¡Probrechito pachacho pachucho!</br>
<a href="https://descargar.one/watch?v=cMeafAJRJKM">Descargar VÍDEO o MP3 HALLOWEEN  Draw My Life (Hacemos  de Tik y Tak)</a><br>Empieza Halloween en TikTak Draw!! En el vídeo de hoy conoceréis los orígenes de la calabazas, uno d</br>