Robot Suite Setup/Teardown - robotframework

How can we keep accessible the Library variables through out test suite
*** Settings ***
Library ClientConnection
# This works
Test Setup Connect Client
Test Teardown Disconnect Client
# while this doesnt
Suite Setup Connect Client
Suite Teardown Disconnect Client
***Keyword***
Connect Client
Connect ${PARAM1} ${PARAM1} #function are specified in Lib ClientConnection
Disconnect Client
Disconnect #function are specified in Lib ClientConnection
*** Tests Cases ***
Test1:
SendMsg #function are specified in Lib ClientConnection depends on object initialized in connect

Related

Connection Arduino on Google Colab

I have tried to connect Arduino Uno to Python code on Colaboratory, to send information to the Arduino using Pysireal library, but I didn't success, I kept reserve this Error on Colab:
" SerialException: [Errno 2] could not open port COM5: [Errno 2] No such file or directory: 'COM5' "
I'm sure that this port is connected, but Colab can't find the port because it’s on local environment.
What can I do to solve this Error ?? is there any way that can I connect my Arduino to Google Colab ?
Hakam Salti.
Thanks.
The Colab instance is connected to computer on the Google cloud (unless you've set up a local instance): the code doesn't execute on your machine, your typing code into a web interface that remotely runs that code, returns the result and it gets displayed back on that interface.
The Arduino is connected to your computer (a PC by the looks of the serial port).
Your question doesn't specify which way the data goes: send Arduino data to Colab, send Colab data to Arduino or bidirectional.
If you had a WIFI connected microcontroller, you could push the data online through an API, like Firebase
For USB, you'd need this sort of connection:
Arduino (OS/serial driver) <-> Browser <-> Colab
To connect the Arduino to the browser you'd need to use WebSerial or an app that has serial access that can also act as a web server (such as a WebSocket server). Since you're using Python for colab you can write a script on your PC that uses pyserial and a websocket server such as Tornado, Flask, etc. (p5.js does something like this with electron in JS and they have prebuilt apps)
The second part is getting that data which is now available to your browser, but locally, available to the Colab notebook. There are multiple ways of doing this, but this WebCam example looks like a good starting point.
Another variant of this might be:
Write a local script that acts as basic web server (http/websocket) and can access the serial port
make that local web server acessible from the internet (ngrok can help here)
access that websocket version from python (via a websocket client or http client pip package)
Update I've posted a couple of options using p5.serialport here.
For reference here are a couple of tested options using the afore mentioned p5.serial (and it's p5.serialcontrol utility):
Option 1: use Jupyter's HTML feature to run client side code (p5.serial) connecting to the p5.serialcontrol utility on your computer:
from google.colab import files
from IPython.display import HTML, Audio
from google.colab.output import eval_js
from base64 import b64decode
C_HTML = """
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.min.js"></script>
<script language="javascript" type="text/javascript" src="https://cdn.jsdelivr.net/npm/p5.serialserver#0.0.29/lib/p5.serialport.js" onload="setupSerial();" onerror="console.warn(e)";></script>
<script>
const serialPort = 'COM13';
let serial;
let isOn = false;
function setupSerial(){
serial = new p5.SerialPort();
serial.open(serialPort);
setInterval(blink, 1000);
console.log("serial setup complete");
}
function blink(){
isOn = !isOn;
if(serial){
serial.write(isOn ? '1' : '0');
}
}
serialInterval = setInterval(checkSerial,500);
function checkSerial(){
console.log('p5.SerialPort',p5.SerialPort);
if(p5.SerialPort){
clearInterval(serialInterval);
setupSerial();
}
}
</script>
"""
def run():
display(HTML(C_HTML))
run()
Option 2: use a reverse tunnel (ngrok) to have the Python side connect to p5.serialcontrol via WebSockets (though you'd need to compose the messages p5.serialcontrol expects maually):
run p5.serialcontrol
run ngrok tcp 8081 from Terminal/Command Prompt (note you may need to setup a free to use auth token for TCP)
install webocket-client on Colab and connect to the websocket (note as opposed to using the p5.serial library in JS, you'd manually put together the messaages to send to p5.serialcontrol's websocket server (e.g. '{"method":"openserial","data":{"serialport":"COM13","serialoptions":{}}}' to open the serial port, '{"method":"write","data":"1"}' to write '1' to serial, etc.))
To install websocket-client in colab you'd use:
!pip install -q websocket-client
and here's an example that turns on LED on for 1 second then off (using the above Arduino example):
from time import sleep
import websocket
# when the websocket is open send a serial open command (on port COM13) then send a '1' then a '0' with 1 second in between
def on_open(ws):
ws.send('{"method":"openserial","data":{"serialport":"COM13","serialoptions":{}}}')
sleep(1)
print('sending ON')
wsapp.send('{"method":"write","data":"1"}')
sleep(1)
print('sending OFF')
wsapp.send('{"method":"write","data":"0"}')
def on_message(ws, message):
print(message)
def on_error(wsapp, err):
print("Got a an error: ", err)
wsapp = websocket.WebSocketApp("ws://YOUR_NGROK_TCP_SERVER_HERE",
# YOUR_NGROK_TCP_SERVER_HERE example #.tcp.ngrok.io:#####,
on_message = on_message,
on_error=on_error)
wsapp.on_open = on_open
wsapp.run_forever()
(also note run_forever() is a blocking loop: based on your application you may want to manually run open and control a websocket connection (as opposed to using WebSocketApp) or use threading, depending on what makes)

Execution of Robot test case is not ending when sleep of 300seconds is added in test case

There is a 300 second wait time in the test case during which the test execution do not communicate with the target and wait for the session to timeout.
Robot Test Case
[Documentation] Test case to verify the session timeout
[Tag] session-timeout
[Timeout] 900 seconds
[Teardown] Disconnect And Unregister If Session Exist
Register With Target
Connect
...
Sleep 300s Wait for session timeout
Verify Session Unregistered
But when I tried running my test case from pycharm the test execution is not ending even after all test steps are executed.
When I tried reducing the 300 seconds delay to 200 seconds the test case execution ends after all the test steps are executed.
I even tried with "Terminate All Processes" in the Suite Teardown. But still the test process is not ending.
Any advise would be of great help!

R plumber Api on cloud foundry deployment got stuck

I have 3 files in a folder - init.r, myapp.r and manifest.yml.
Manifest file contains information for deployment on cloud foundry. I am using https://github.com/beibeiyang/cf-buildpack-r.git buildpack for deployment.
myapp.r contains a very simple function that returns output whatever it gets as input and it is using get request with # annotation.
#* #get /mypath
abc <- function(input1){
return(input1)
}
init.r contains following code:
install.packages("plumber")
library(plumber)
r <- plumb("myapp.r")
r$run(port=8056)
It is fine when I run this code in local using R studio. But when I deploy it to cloud foundry, it got stuck after saying: Starting server to listen on port (8056 or any other port). It waited for 15 minutes and failed to start. No progress after that. Anyone has any idea what is happening here?
Your app is monitored by a health checker. With its default setting of port (see --health-check-type option of cf push), it repeatedly tries to connect to the app container's default port (8080) to check if your app has started successfully. And eventually it times out, as your app is not responding to requests on that port.
Try again with port 8080 instead of 8056, or better, the port number passed in to your app through the PORT environment variable (see http://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#PORT).

Call Transfer to Different Host/IP in Asterisk

Is it possible to transfer call to different host in asterisk?
Like I have three asterisk instances in line i.e A, B and C. The scenario is that the call will come from A to B and B will transfer the call to C and after successful transfer, B will not be facilitator and A will directly be communicating with C
Correct setup is have kamailio or opensips proxy infront of asterisk.
For asterisk ff you have on all instances in trunks settings
canreinvite=yes
directmedia=yes
and if you have SIP protocol, you can do Transfer call. If you do that before call setup will be full transfer,if after setup - only last option will work, so signaling will still go via this host, while media go directly.
Both options may not work if provider NOT support that.
pro-sip*CLI> core show application Transfer
-= Info about application 'Transfer' =-
[Synopsis]
Transfer caller to remote extension.
[Description]
Requests the remote caller be transferred to a given destination. If TECH
(SIP, IAX2, LOCAL etc) is used, only an incoming call with the same channel
technology will be transferred. Note that for SIP, if you transfer before
call is setup, a 302 redirect SIP message will be returned to the caller.
The result of the application will be reported in the ${TRANSFERSTATUS}
channel variable:
${TRANSFERSTATUS}:
SUCCESS: Transfer succeeded.
FAILURE: Transfer failed.
UNSUPPORTED: Transfer unsupported by channel driver.
[Syntax]
Transfer([Tech/]destination)
[Arguments]

Unable to push Sample R Shiny App to Bluemix

I have been following this tutorial and when I go to "push" the sample application onto IBM Bluemix it fails in creating the instance. I am using a custom buildpack and that is successful in installing all the neccessary R files and etc.
My command to push the application onto Bluemix: cf push MyNewShinyApp -b https://github.com/aruizga7/cf-buildpack-r.git
The error I receive is: Failed to accept connection within health check timeout... (on command prompt)
and on Bluemix I receive this error:
an instance of the app crashed: failed to accept connections within health check timeout
exit status: 1, CRASHED

Resources