Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cb2596bd814f
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 88e0aae16d76
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 9, 2015

  1. Copy the full SHA
    f427041 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    88e0aae View commit details
Showing with 39 additions and 3 deletions.
  1. +3 −3 artiq/coredevice/comm_serial.py
  2. +36 −0 artiq/coredevice/comm_tcp.py
6 changes: 3 additions & 3 deletions artiq/coredevice/comm_serial.py
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@

class Comm(CommGeneric, AutoDB):
class DBKeys:
serial_dev = Parameter()
baud_rate = Parameter(115200)
serial_dev = Argument()
baud_rate = Argument(115200)

def open(self):
if hasattr(self, "port"):
@@ -31,7 +31,7 @@ def close(self):

def read(self, length):
r = bytes()
while(len(r) < length):
while len(r) < length:
r += self.port.read(length - len(r))
return r

36 changes: 36 additions & 0 deletions artiq/coredevice/comm_tcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import logging
import socket

from artiq.coredevice.comm_generic import CommGeneric
from artiq.language.db import *


logger = logging.getLogger(__name__)


class Comm(CommGeneric, AutoDB):
class DBKeys:
host = Argument()
port = Argument(1381)

def open(self):
if hasattr(self, "socket"):
return
self.socket = socket.create_connection((self.host, self.port))
logger.debug("connected to host %s on port %d", self.host, self.port)

def close(self):
if not hasattr(self, "socket"):
return
self.socket.close()
del self.socket
logger.debug("disconnected")

def read(self, length):
r = bytes()
while len(r) < length:
r += self.socket.recv(min(8192, length - len(r)))
return r

def write(self, data):
self.socket.sendall(data)