GithubHelp home page GithubHelp logo

cctools's People

Contributors

nicolasdeleplace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cctools's Issues

TypeError on Serial Write

I'm trying to access my Wh EMP800 with CCT 910 using ccTools.

Environment: Linux Mint 17 AMD64 (based on Ubuntu 14.04)

CCT 910 info (lsusb -v):

Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0403 Future Technology Devices International, Ltd
  idProduct          0x6001 FT232 USB-Serial (UART) IC
  bcdDevice            6.00
  iManufacturer           1 wh Berlin
  iProduct                2 CCT 900
  iSerial                 3 whCCT018266
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              2 CCT 900
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0

Tried to run the basic example from your blog post, on virtualenv:

import serial
import time
from tools.ccTalk import *

ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)


def send_message(header, data='', source=1, destination=2):
    req = ccTalkMessage(header=header, payload=data, source=source,
                        destination=destination)
    req.setPayload(header, data)
    ser.write(req)
    data = ser.read(50)
    messages = parseMessages(data)
    for message in messages:
        print message


init = ccTalkMessage()
init.setPayload(254)

ok = False

# Wait for device to be initiated
while ok != True:
    ser.write(init)
    data = ser.read(50)
    try:
        messages = parseMessages(data)
        response = messages[-1]
        print response
    except:
        continue
    if response.payload.header == 0:
        ok = True
    else:
        print response.payload.header

# Set inhibit status to allow all
send_message(231, '\xff\xff')

#Set master inhibit status to enable device
send_message(228, '\x01')

#Read buffered credit or error codes
event = 0
while True:
    try:
        request = ccTalkMessage()
        request.setPayload(229)
        ser.write(request.__str__())
        data = ser.read(50)
        messages = parseMessages(data)
        for message in messages:
            if message.payload.header == 0:
                data = message.payload.data
                if ord(data[0]) > event:
                    event = ord(data[0])
                    print "Counter  : " + str(ord(data[0]))
                    print "Credit 1 : " + str(ord(data[1])),
                    print "Error  1 : " + str(ord(data[2]))
                    print "Credit 2 : " + str(ord(data[3])),
                    print "Error  2 : " + str(ord(data[4]))
                    print "Credit 3 : " + str(ord(data[5])),
                    print "Error  3 : " + str(ord(data[6]))
                    print "Credit 4 : " + str(ord(data[7])),
                    print "Error  4 : " + str(ord(data[8]))
                    print "Credit 5 : " + str(ord(data[9])),
                    print "Error  5 : " + str(ord(data[10]))
        time.sleep(0.2)
    except KeyboardInterrupt, e:
        print "Quitting..."
        break
ser.close()

And that's the error:

Traceback (most recent call last):
  File "/home/marjinal1st/Development/PycharmProjects/CoinTests/src/test-02.py", line 26, in <module>
    ser.write(init)
  File "/home/marjinal1st/Development/PycharmProjects/CoinTests/local/lib/python2.7/site-packages/serial/serialposix.py", line 491, in write
    d = to_bytes(data)
  File "/home/marjinal1st/Development/PycharmProjects/CoinTests/local/lib/python2.7/site-packages/serial/serialutil.py", line 75, in to_bytes
    for item in seq:
TypeError: iteration over non-sequence

I made some debugs using PyCharm, this is some debug information I could get when the exception is thrown:

debug

Any ideas?

Can't Dispense Coins From Hopper

I've a coin hopper and I'm trying to dispense coins. But I'm always getting NAK response for the 167 Header.

Normally, all the ccTalk documents I've found says: Get the serial number with 242 header and add number of coins to dispense as hex. Concatenate them and send them as data with 167 header.

My test program:

import serial
from tools.ccTalk import *

ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=0.2)


def sendMessage(header, data='', source=1, destination=3):
    request = ccTalkMessage(header=header, payload=data, source=source, destination=destination)
    print " -> " + str(request)
    ser.write(request.raw())
    data = ser.read(50)
    messages = parseMessages(data)[1]
    print " <- " + str(messages[1])
    print("Data: %s\n" % messages[1].payload.data)
    return messages[1]


print "[*] Pinging device..."

ok = False

# Wait for device to be initiated
while not ok:
    try:
        response = sendMessage(254)
    except:
        continue
    if response.payload.header == 0:
        ok = True
    else:
        print response.payload.header

print "[*] Request manufacturer id ..."
sendMessage(246)

print "[*] Request product code"
sendMessage(244)

print "[*] Enable hopper"
sendMessage(164)

print "[*] Getting serial number"
sr = sendMessage(242).payload.data

print "[*] Dispensing coins..."
sendMessage(167, sr + '\x01')

And my output is:

[*] Pinging device...
 -> <cctalk src=1 dst=3 length=0 header=254 signature=checksum>
 <- <cctalk src=3 dst=1 length=0 header=0 signature=checksum>
Data: 

[*] Request manufacturer id ...
 -> <cctalk src=1 dst=3 length=0 header=246 signature=checksum>
 <- <cctalk src=3 dst=1 length=10 header=0 data=484f505045522053726c signature=checksum>
Data: HOPPER Srl

[*] Request product code
 -> <cctalk src=1 dst=3 length=0 header=244 signature=checksum>
 <- <cctalk src=3 dst=1 length=14 header=0 data=554348312d4e4f454e4352595054 signature=checksum>
Data: UCH1-NOENCRYPT

[*] Enable hopper
 -> <cctalk src=1 dst=3 length=0 header=164 signature=checksum>
 <- <cctalk src=3 dst=1 length=0 header=0 signature=checksum>
Data: 

[*] Getting serial number
 -> <cctalk src=1 dst=3 length=0 header=242 signature=checksum>
 <- <cctalk src=3 dst=1 length=3 header=0 data=bdb65b signature=checksum>
Data: ��[

[*] Dispensing coins...
 -> <cctalk src=1 dst=3 length=4 header=167 data=bdb65b01 signature=checksum>
 <- <cctalk src=3 dst=1 length=0 header=5 signature=checksum>
Data:

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.