def write_translated(self, name, value, event): """Send a translated write request to the VI. """ data = {'name': name} if value is not None: data['value'] = self._massage_write_value(value) if event is not None: data['event'] = self._massage_write_value(event); message = JsonFormatter.serialize(data) bytes_written = self.write_bytes(message) assert bytes_written == len(message) return bytes_written
def main(): configure_logging() arguments = parse_options() if arguments.split == 'trip': splitter = TripSplitter() else: splitter = TimeSplitter(arguments.split) for key, split in list(splitter.split(arguments.files).items()): with open("%s.json" % key, 'w') as output_file: for record in split: output_file.write(JsonFormatter.serialize(record) + "\n")
def main(): configure_logging() arguments = parse_options() if arguments.split == "trip": splitter = TripSplitter() else: splitter = TimeSplitter(arguments.split) for key, split in splitter.split(arguments.files).items(): with open("%s.json" % key, "w") as output_file: for record in split: output_file.write(JsonFormatter.serialize(record) + "\n")
def write_translated(self, name, value, event): """Format the given signal name and value into an OpenXC write request and write it out to the controller interface as bytes, ending with a \0 character. """ data = {'name': name} if value is not None: data['value'] = self._massage_write_value(value) if event is not None: data['event'] = self._massage_write_value(event); message = JsonFormatter.serialize(data) bytes_written = self.write_bytes(message + "\x00") assert bytes_written == len(message) + 1 return bytes_written
def write_translated(self, name, value, event): """Format the given signal name and value into an OpenXC write request and write it out to the controller interface as bytes, ending with a \0 character. """ data = {'name': name} if value is not None: data['value'] = self._massage_write_value(value) if event is not None: data['event'] = self._massage_write_value(event) message = JsonFormatter.serialize(data) bytes_written = self.write_bytes(message + "\x00") assert bytes_written == len(message) + 1 return bytes_written
def write_raw(self, message_id, data, bus=None): """Send a raw write request to the VI. """ if not isinstance(message_id, numbers.Number): try: message_id = int(message_id, 0) except ValueError: raise ValueError("ID must be numerical") data = {'id': message_id, 'data': data} if bus is not None: data['bus'] = bus message = JsonFormatter.serialize(data) bytes_written = self.write_bytes(message) assert bytes_written == len(message) return bytes_written
def write_raw(self, message_id, data): """Format the given CAN ID and data into a JSON message and write it out to the controller interface as bytes, ending with a \0 character. TODO this could write to a separate USB endpoint that is expecting raw-style JSON messages. """ if not isinstance(message_id, numbers.Number): try: message_id = int(message_id, 0) except ValueError: raise ValueError("ID must be numerical") message = JsonFormatter.serialize({'id': message_id, 'data': data}) bytes_written = self.write_bytes(message + "\x00") assert bytes_written == len(message) + 1 return bytes_written
def complex_request(self, request, wait_for_first_response=True): """Send a compound command request to the interface over the normal data channel. request - A dict storing the request to send to the VI. It will be serialized to JSON, as that is the only supported format for commands on the VI in the current firmware. wait_for_first_response - If true, this function will block waiting for a response from the VI and return it to the caller. Otherwise, it will send the command and return immediately and any response will be lost. """ self.write_bytes(JsonFormatter.serialize(request)) response = None if wait_for_first_response: response = self._wait_for_response(request) return response
def receive(message, **kwargs): message['timestamp'] = time.time() print((JsonFormatter.serialize(message)))
def receive(message, **kwargs): """Receive Routine @param message the message object instance. @param kwargs the kwargs object instance.""" message['timestamp'] = time.time() print(JsonFormatter.serialize(message))
def receive(message, **kwargs): message['timestamp'] = time.time() print(JsonFormatter.serialize(message))