The first step is to confirm you know exactly which com port your device is on, here is a guide for USB Serial devices in Window
Next unplug the USB serial port from the usb bus and plug it back into another port and check if it gets the same com port (Windows had a habit of making devices address change)
Once you know the port is reliably consistent, check the Port Settings (bits per second, etc) match the settings needed for your device under test.
Here COM10 is the port where the device is connected to USB
For this COM port only am going to send PID values to the device via USB communication. Below are the sample code
*** Test Cases ***
Connect to a broker with default port and client id
SerialLibrary.Add Port COM10
SerialLibrary.Open Port COM10
#${port}= SerialLibrary.Get Current Port Locator #Log ${port}
SerialLibrary.Port Should Be Open
${listofports}= SerialLibrary.List Com Port Names
Log ${listofports}
After this am not clear on how to send PID commands to the device and to read those success statuses if the PID values succeed
Pls let me know how to pass those PID values to the device
OK it looks like you’ve identified the port and it looks like the SerialLibrary has successfully opened that port. as SerialLibrary.Port Should Be Open passed, this is a good start.
Serial communication is actually quite simple, you send ASCII stings and get ASCII responses. I’m not sure what “PID commands” are, probably something unique to your device?
I know for dial up modems there was the AT command standard set of strings (most started with AT) that were used for configuring and instructing a modem how to dial numbers and connect to remote systems.
So guessing your PID commands are something similar then you would probably just send the PID commands with Write Data and read the response with one of the Read Data keywords
Based on the README and the help file, I’d try something basic like this:
*** Test Cases ***
Connect to a broker with default port and client id
SerialLibrary.Add Port COM10
SerialLibrary.Open Port COM10
#${port}= SerialLibrary.Get Current Port Locator
#Log ${port}
SerialLibrary.Port Should Be Open COM10
#${listofports}= SerialLibrary.List Com Port Names
#Log ${listofports}
SerialLibrary.Write Data ${PID_Command} COM10
${response}= SerialLibrary.Read All Data COM10
#Log ${response}
I tried with above code by adding value to write data as shown below
Variable
${PID_Command} 200
*** Test Cases ***
Connect to a broker with default port and client id
SerialLibrary.Add Port COM10
SerialLibrary.Open Port COM10
#${port}= SerialLibrary.Get Current Port Locator #Log ${port}
SerialLibrary.Port Should Be Open COM10
#${listofports}= SerialLibrary.List Com Port Names #Log ${listofports}
SerialLibrary.Write Data ${PID_Command} COM10
${response}= SerialLibrary.Read All Data COM10 #Log ${response}
I have a doubt, currently am trying this use-case for the telematics device which has some commands like remote on,off etc. which has PID values like 201,250 etc. as mentioned earlier.
I passed those values as you have mentioned in the above codes where am not able to turn on or off the device but the code is getting pass
Unfortunately I doubt anyone here will be able to help you with that, you sent a command and got a response which you were able to read, so that’s a great start.
From here you are probably going to need to work with someone who knows the devices you are testing and what those responses mean.
You might need to send an end of line character or something like that, but that’s just a guess.