Read a specific number or all packets from a candump file. :param count: Specify a specific number of packets to be read. All packets can be read by count=-1. :return: A PacketList object containing read CAN messages
(self, count=-1)
| 673 | callback(p) |
| 674 | |
| 675 | def read_all(self, count=-1): |
| 676 | # type: (int) -> PacketList |
| 677 | """Read a specific number or all packets from a candump file. |
| 678 | |
| 679 | :param count: Specify a specific number of packets to be read. |
| 680 | All packets can be read by count=-1. |
| 681 | :return: A PacketList object containing read CAN messages |
| 682 | """ |
| 683 | res = [] |
| 684 | while count != 0: |
| 685 | try: |
| 686 | p = self.read_packet() |
| 687 | if p is None: |
| 688 | continue |
| 689 | except EOFError: |
| 690 | break |
| 691 | count -= 1 |
| 692 | res.append(p) |
| 693 | return PacketList(res, name=os.path.basename(self.filename)) |
| 694 | |
| 695 | def recv(self, size=CAN_MTU): |
| 696 | # type: (int) -> Optional[Packet] |
no test coverage detected