Skip to content

Conversation

@marc-roeoesli
Copy link
Contributor

@marc-roeoesli marc-roeoesli commented May 4, 2022

Extend read function of serialdriver and externalconsoledriver with 'max_size' argument that limits the number of read bytes to 'max_size'. Set 'size' = 'max_size' to read exactly 'size' bytes. The values 'None' and '0' result in an unlimited read.
Extend 'test_read' in test_serialdriver.py and test_externalconsoledriver.py to check 'max_size' argument.
Implement 'max_size' explicitely in consoleexpectmixin.

  • We use the feature to read a fixed number of bytes on the serial port during testing the serial communication. The current read function returns the full buffer of the serial port (maximum of size and in_waiting). We use labgrid to test embedded software on hardware devices.
  • We think that for certain tests it can be useful to read a well defined and fixed size from the serial port. We hope that this could also be useful for other developers. We are open to discuss other possibilities/suggestions.
  • We tested the feature by extending the existing test for the serial driver and external console driver 'read'-function.

Checklist

  • Documentation for the feature
  • Tests for the feature
  • Add a section on how to use the feature to doc/usage.rst
  • CHANGES.rst has been updated
  • PR has been tested
  • Man pages have been regenerated

Signed-off-by: Marc Roeoesli marc.roeoesli@mt.com

@codecov
Copy link

codecov bot commented May 10, 2022

Codecov Report

Merging #912 (b4504ca) into master (1d1cecb) will increase coverage by 0.0%.
The diff coverage is 100.0%.

❗ Current head b4504ca differs from pull request most recent head f5226ed. Consider uploading reports for the commit f5226ed to get more accurate results

@@          Coverage Diff           @@
##           master    #912   +/-   ##
======================================
  Coverage    56.8%   56.8%           
======================================
  Files         149     149           
  Lines       11091   11096    +5     
======================================
+ Hits         6301    6306    +5     
  Misses       4790    4790           
Impacted Files Coverage Δ
labgrid/driver/consoleexpectmixin.py 74.0% <100.0%> (+0.9%) ⬆️
labgrid/driver/externalconsoledriver.py 82.3% <100.0%> (+0.8%) ⬆️
labgrid/driver/serialdriver.py 81.4% <100.0%> (+0.4%) ⬆️
labgrid/remote/config.py 90.0% <0.0%> (-0.5%) ⬇️
labgrid/remote/exporter.py 60.4% <0.0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d1cecb...f5226ed. Read the comment docs.

@marc-roeoesli marc-roeoesli changed the title RFC: add read_block option to serialdriver read RFC: add max_size option to serialdriver read May 13, 2022
@marc-roeoesli marc-roeoesli force-pushed the rfc_serialdriver_read branch from b0dfbc9 to 96c8fd6 Compare May 13, 2022 14:59
@Emantor Emantor changed the title RFC: add max_size option to serialdriver read Add max_size option to ConsoleExpectMixin read May 27, 2022
@Emantor
Copy link
Member

Emantor commented May 27, 2022

IMO the RFC from the commit message can be removed.

Implement 'max_size' parameter to limit the maximal number of bytes
read and returned by the 'read'-function of the serial driver and the
externalconsole driver. 'max_size' defaults to 'None'. Values
'None' and '0' do not limit the maximal amount of read bytes.
Set 'size' = 'max_size' to read well defined and fixed number of bytes.

Adapt ConsoleExpectMixin accordingly, and include 'max_size' as explict
parameter.
Adapt 'test_serialdriver' to test the 'max_size' parameter.
Adapt 'test_externalconsoledriver' to test the 'max_size' parameter.

Signed-off-by: Marc Roeoesli <marc.roeoesli@mt.com>
@jluebbe jluebbe force-pushed the rfc_serialdriver_read branch from b4504ca to f5226ed Compare June 16, 2022 09:56
@jluebbe
Copy link
Member

jluebbe commented Jun 16, 2022

I've squashed the commits together and made minor changes to the message. I've also removed the RFC tag.

@jluebbe jluebbe merged commit f4a8962 into labgrid-project:master Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants