Jump to content

Problems with TTL on Orange Pi Lite


Recommended Posts

Hello,

 

I try to setup my Orange Pi Lite with a thermal printer (http://www.ebay.de/itm/122418910118?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT). With my Arduino the printer works perfect, so it is actually ok. I just can't figure out how to use the ttl connection. I installed pyA20 and try to implement a kind of SoftwareSerial and it didn't worked really well:

 

#!/usr/bin/env python
"""Basic blinking led example.

The led on A20-OLinuXino-MICRO  blinks with rate of 1Hz like "heartbeat".
"""

import os
import sys
import time

if not os.getegid() == 0:
    sys.exit('Script must be run as root')


from time import sleep
from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector

tx = port.PA11
rx = port.PA12

baud = 1.0/9600.0


def sendTx(sendCharASCII):
    sendByte = '{0:b}'.format(sendCharASCII).zfill(8)
    sendByte = sendByte[::-1]
    print(sendByte)
    sendByteInt = [int(bit) for bit in sendByte]
    gpio.output(tx,0)
    time.sleep(baud)
    for bit in sendByteInt:
        #print('sending '+bit)
        gpio.output(tx,bit)
        time.sleep(baud)
    gpio.output(tx,1)
    time.sleep(0.01)


gpio.init()
gpio.setcfg(tx, gpio.OUTPUT)
gpio.setcfg(rx, gpio.OUTPUT)

gpio.output(tx,1)
gpio.output(rx,0)
sleep(1)


sendTx(ord('a'))
sendTx(ord('b'))
sendTx(ord('c'))
sendTx(ord('d'))
sendTx(ord('e'))
sendTx(ord('f'))
sendTx(ord('g'))
sendTx(ord('h'))
sendTx(ord('i'))
sendTx(ord('j'))
sendTx(ord('k'))
sendTx(ord('l'))
sendTx(ord('m'))
sendTx(ord('n'))
sendTx(ord('o'))
sendTx(ord('p'))
sendTx(ord('q'))
sendTx(ord('r'))
sendTx(ord('s'))
sendTx(ord('t'))
sendTx(ord('u'))
sendTx(ord('v'))
sendTx(ord('w'))
sendTx(ord('x'))
sendTx(ord('y'))
sendTx(ord('z'))

sendTx(10)
sendTx(10)
sendTx(10)

I printed out some cryptic signes. The cool thing is, that if i change the baud sleep time to something smaller, it actually prints sometimes the right letters. That means python is just too slow. Can anyone help to setup a ttl connection to the printer? I've googled alot, but I just can't find anything helpfull :( Currently I use pins PA11 and PA12, is this right?

 

Greets,

Chris

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines