Here is a sample script to receive Data from Hyper Terminal to a Magelis HMI using Script Driver:
// 1. Create script variables
// For reading messages from hyperterminal
int result;
byte readArray[]= new byte[20];
// 2. Read data from serial port
result = HyperTerminal.read(0, 20, readArray);
if (result <= 0) // Check for error
ReadText.write("ERROR"); // Write to variable
else
{
// Convert byte array to String
String temp = new String( readArray );
ReadText.write(temp);
}