ezLCD+102 Lua Rs232Tx() and ExitReq()

13 views
Skip to first unread message

Daniel Fowler

unread,
Jul 24, 2009, 5:16:27 PM7/24/09
to ezLCD+ Support Group
I just got the +102 and managed to run a few programs on it. I got it
to detect a button press and release and change the screen without
issue. But when I tried to report button events over the RS232
interface the messages get scrambled. It always seems to transmit the
first character without problem, but the next is often corrupted.
Even when printing single characters, garbage and sometimes spaces are
sent between some of the messages. Also the larger string gets
heavily garbled. My code is provided below.

Also, ExitReq() seems to output true at all times. Is there a pin or
something i need to set / ground? I copied the following code from
the Lua Manuel which seems to exit immediately rather then when i send
the request from ezLuaIDE.

while not ExitReq() do
end


Any insights would be greatly appreciated.

--The current code--------------------------------------------

test = 0

function ButtonHandler(id, event)
ez.Button(id, event)
if event == 2 then
ez.Rs232Tx("x")
ez.Rs232Tx(id + 30)
ez.Rs232Tx("\r")
elseif event == 1 then
ez.Rs232Tx("r")
ez.Rs232Tx(id + 30)
ez.Rs232Tx("\r")
end
test = event - 1
end

-- Select Display & Draw Frames
ez.DelButtons()
ez.SetDispFrame(0)
ez.SetDrawFrame(0)
ez.Rs232Open(115200,0,1,0)
ez.Cls(ez.RGB(255, 255, 255))

ez.SetFtFont(1, 64, 0)
ez.SetColor(ez.RGB(0, 0, 0))
ez.SetXY(10, 10)
print("button_switch!")
ez.Rs232Tx("This is a test string, do not be alarmed\r")

ez.Button(0, 1, 1,0,255,100,100)
ez.SetButtonEvent("ButtonHandler")

--while not ExitReq() do
while true do
if test == 1 then
-- ez.SetColor(ez.RGB(255, 0, 0))
-- ez.Polygon(100, 100, 100, 200, 200, 200, 200, 100)
else
-- ez.SetColor(ez.RGB(0, 255, 0))
-- ez.Polygon(100, 100, 100, 200, 200, 200, 200, 100)
end
end
ez.Rs232Close()

--
end-----------------------------------------------------------------------------
I have also tried ("x0\r"), ("x0"), ("x0\r", 3), ("x0", 2), and ("x0",
3) in case i needed to count a null character

I loaded firmware version 2.2 on it and the following appears in my
UserConfig.txt:

SerialNo = 0
SplashScreen = None
BackLight = 255
BacklightOn = True
TouchProtocol = ezButton
StartupTxInterface = None
Rs232Enabled = Yes
Rs232Baudrate = 115200
Rs232StopBits = 1
Rs232Parity = None
Rs232Handshake = None
SpiEnabled = Yes
I2cEnabled = No
DacEnabled = No
Ac97Enabled = No
ParEnabled = No
SDUserConfig = None
MacEnabled = Yes
MacAddressHi = 0x181F
MacAddressLo = 0x008C0001
NetIpAddress = 192.168.1.6
NetSubnetMask = 192.168.255.255
NetGateway = 192.168.1.1
NetDns = None
NetAltDns = None
Demos = 0b11111
DemoInterval = 5
StartupLua = 0


Output from terra-term when I press and release the button about 20
times:

þThis is a teÍGn§&Næ;Ƕ3d•ot beçÆ'~W&×üx
r5ÿx5ÿr
xyÖüryÖüx5ÿryÖüx
r
x
r5ÿx
r5ÿx
r
xyÖür
xyÖür5ÿx5ÿr5ÿx
r5ÿx
r
x
r5ÿx5ÿryÖüx
ryÖüxyÖür
xyÖür5ÿx
r5ÿx
ry


the only recognizable number is ‘5’ but the id should be 0. I added
30 to translate the number to an ASCII value (‘0’ = 30)

CityHall

unread,
Jul 24, 2009, 5:37:32 PM7/24/09
to ezLCD+ Support Group
I just noticed that ASCII '0' = 48 (0x30) not 30, fixed that part but
still getting garbled output.

This iÍ>:est stÉJöwÿüx05ÿr0
x0
rÁÖüx05ÿr05ÿx0
rÁÖüx0
r0
x05ÿrÁÖüx05ÿrÁÖüx0
r05ÿx0
rÁÖüxÁÖürÁÖüx05ÿr0
xÁÖür05ÿx0
r05ÿx05ÿr0
x0
r05

CityHall

unread,
Jul 27, 2009, 12:54:21 PM7/27/09
to ezLCD+ Support Group
Never mind, I should have paid more attention to the Rs232Open()
function argument description.

Thanks to lcdking for Rs232Test.lua, helped me identify the problem.


ez.Rs232Open("RS232RXHandler", 115200,0,1,0)
I wanted 0 parity bits, 1 stop bit, and no (0) handshaking
I apparently set it up to have even parity, 1.5 stop bits and no
handshaking.
Reply all
Reply to author
Forward
0 new messages