# Read data not working in SerialLibrary

**URL:** <https://forum.robotframework.org/t/read-data-not-working-in-seriallibrary/7239>\
**Category:** Standard Libraries\
**Created:** [30 April 2024 13:18 UTC](https://forum.robotframework.org/t/read-data-not-working-in-seriallibrary/7239 "2024-04-30T13:18:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenbates101](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/stephenbates101/32/3789_2.png) [@stephenbates101](https://forum.robotframework.org/u/stephenbates101)\
**Post date:** [30 April 2024 13:18 UTC](https://forum.robotframework.org/t/read-data-not-working-in-seriallibrary/7239/1 "2024-04-30T13:18:12Z")

</div>

Hi All,

I am trying to connect to a Linux device and test using the SerialLibrary, I am currently testing with a teensy board connected to COM31, it has a simple program to send the incoming data to a second serial port and send a response to COM31.  
I can see the expected data from the teensy’s second serial port but no response data is recorded by SerialLibrary.

This is my resource code for SerialLibrary;

\*\*\* Settings \*\*\*  
Documentation Connect to a Charger Unit using via Serial Port  
Library SerialLibrary

\*\*\* Variables \*\*\*  
${USERNAME} root\r  
${PASSWORD} password\r  
${RETURN} \r  
${CHARGER PORT} COM31

\*\*\* Keywords \*\*\*  
List My Com Ports  
@{ports} = List Com Ports  
Log ${ports[0].device}

Open Serial Port  
Add Port ${CHARGER PORT}  
… baudrate=115200  
… bytesize=8  
… parity=N  
… stopbits=1  
… timeout=999  
sleep 1s  
Open Port ${CHARGER PORT}  
sleep 1s

Serial Port Log in  
Write Data ${RETURN} encoding=ascii port\_locator=${CHARGER PORT}  
${read} = Read All And Log loglevel=debug encoding=ascii port\_locator=${CHARGER PORT}  
sleep 1s  
Write Data ${USERNAME} encoding=ascii port\_locator=${CHARGER PORT}  
${read} = Read All And Log loglevel=debug encoding=ascii port\_locator=${CHARGER PORT}  
sleep 1s  
Write Data ${PASSWORD} encoding=ascii port\_locator=${CHARGER PORT}  
${read} = Read All And Log loglevel=debug encoding=ascii port\_locator=${CHARGER PORT}  
sleep 1s

Serial Check for Version  
Write Data cat /opt/ovo/version.txt encoding=ascii port\_locator=${CHARGER PORT}  
${read} = Read All And Log loglevel=debug encoding=ascii port\_locator=${CHARGER PORT}  
sleep 1s

And this is output form my test;

[info] Starting the test case to connect via Serial Port  
[info (+0.01s)] @{ports} = [COM13 - Silicon Labs CP210x USB to UART Bridge (COM13) | COM1 - Communications Port (COM1) | COM31 - USB Serial Device (COM31)]  
[info] COM13  
[info (+1.01s)] Slept 1 second.  
[info (+1.01s)] Slept 1 second.  
[info] ${read} = None  
[info (+1.01s)] Slept 1 second.  
[info] ${read} = None  
[info (+1.00s)] Slept 1 second.  
[info (+0.01s)] ${read} = None  
[info (+1.01s)] Slept 1 second.  
[info (+0.01s)] ${read} = None  
[info (+1.01s)] Slept 1 second.  
Should be able to open a Serial Connection to a Charger :: This is… | PASS |

Can anyone help please?

Many thanks

Stephen

---

<div class="post-metadata">

**Author:** ![stephenbates101](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/stephenbates101/32/3789_2.png) [@stephenbates101](https://forum.robotframework.org/u/stephenbates101)\
**Post date:** [1 May 2024 06:41 UTC](https://forum.robotframework.org/t/read-data-not-working-in-seriallibrary/7239/2 "2024-05-01T06:41:12Z")

</div>

Hi all,  
I’ve solved this problem, I need to use Read Until and have specific character at the end of each response like “/r”.

> **[Utilize Robot Framework for Hardware-In-The-Loop (HIL) Testing - DornerWorks](https://www.dornerworks.com/blog/robot-framework-tutorial/)**
>
> To better describe how robot framework can be utilized for HIL testing, we will do a step-by-step walkthrough of developing and running tests for Linux running on a Raspberry Pi (3b). All of the code used in this tutorial can be found at...

Regards  
Stephen
