Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problems with TTL on Orange Pi Lite

Featured Replies

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

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.