how to use pyserial in pci modem interaction

Asked

Viewed 67 times

1

I am trying to create a program that dials for certain numbers call twice and change to the next number.

I am using pyserial for communication with pci modem only the program occupies the port but the modem does not dial.

So I installed a serial port emulator to see if the program was sending the right string to port and the string emulator is sending but the modem does not run.

if anyone can help me I thank you. I also tested the string in hypertermial worked normally

follows the code :

import serial
import time

#leitura da lista de tp
#Arquivo de leitura deve estar no mesmo diretorio do programa
porta ='COM3'
vel =115200
bytesize=8



arq = open("TP.txt",'r')
resul=arq.readlines()
arq.close()
ddd=input('Digite codigo DDD')
for i in range(len(resul)):
    resul[i].format(resul[0:8])
    tel=('ATDT'+ddd+resul[i]).rstrip('\t\n')
    print(tel)           
    if(i>=0):
        print('Enviando numero '+tel)
        try:
            con = serial.Serial(porta,vel,bytesize,parity='N',stopbits=1,timeout=1)
            con.write(tel.encode('utf-8'))
            time.sleep(1.8)
            con.close()
        except serial.SerialException:
             print("ERRO: Verifique se ha algum dispositivo conectado na porta!") 
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.