Author Topic: [SOLVED] Writing to Uart  (Read 787 times)

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
[SOLVED] Writing to Uart
« on: July 06, 2016, 12:25:41 pm »
I am testing some simple Uart.write

This is what I want to send
t1.txt="Hello" but I also need to add 0xFF 0xFF 0xFF at the end.

So this is what I did

Code: [Select]
        Dim test As String
        test = "t1.txt=\x22Hello\x22"
        serial.Write(test)
        serial.Write(0xff)
        serial.Write(0xff)
        serial.Write(0xff)

But every time I run this code the device freezes and i receive the error message "Can't read the data from the device."

I debugged it and the problem seems to be right after doing the first Write.

I tested it also like this
Code: [Select]
serial.Write(0x74)
        serial.Write(0x31)
        serial.Write(0x2e)
        serial.Write(0x74)
        serial.Write(0x78)
        serial.Write(0x74)
        serial.Write(0x3d)
        serial.Write(0x22)
        serial.Write(0x48)
        serial.Write(0x65)
        serial.Write(0x6c)
        serial.Write(0x6c)
        serial.Write(0x6f)
        serial.Write(0x22)
        serial.Write(0xff)
        serial.Write(0xff)
        serial.Write(0xff)

But same thing happens with same error message as above.

I am using the latest version of all software/firmware
« Last Edit: July 20, 2016, 02:06:08 am by kristofferis »

Share on Facebook Share on Twitter


mc-Abe

  • Full Member
  • ***
  • Posts: 167
    • View Profile
    • mc-Things
Re: Writing to Uart
« Reply #1 on: July 07, 2016, 06:30:02 pm »
I have been able to reproduce this problem. I will get to the bottom of it and let you know.

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Writing to Uart
« Reply #2 on: July 07, 2016, 06:37:04 pm »
Thanks Abe.
It's good that you could reproduce it, that makes the troubleshooting so much easier.

mc-Abe

  • Full Member
  • ***
  • Posts: 167
    • View Profile
    • mc-Things
Re: Writing to Uart
« Reply #3 on: July 08, 2016, 02:23:44 pm »
We have tracked this issue and has been resolved. You will have a solution in the next version of mcStudio. Meanwhile if you can create a string like so "\xFF\xFF\xFF" and use that instead of individual bytes, you should be able to work around this issue.

The problem is specifically in the byte write overload. The string write works fine.

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Writing to Uart
« Reply #4 on: July 08, 2016, 02:30:14 pm »
Ahh great work and fast as usual.
Thanks for the workaround  :)

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Writing to Uart
« Reply #5 on: July 17, 2016, 07:22:56 am »
I have tried the workaround and also now with the new version writing byte but there seems to be problem with the 0xff

It's like the receiving part does not get that byte and if I send 0xff to mcModule it does not receive it, or at least it does not show in the Read function.

This is what i tried to send to mcModule
Code: [Select]
0x65 0x00 0x08 0x01 0xff 0xff 0xffbut i only received
Code: [Select]
0x65 0x00 0x08 0x01

mc-Abe

  • Full Member
  • ***
  • Posts: 167
    • View Profile
    • mc-Things
Re: Writing to Uart
« Reply #6 on: July 18, 2016, 06:56:23 pm »
This is a bug will be fixed on the next release. 0xFF gets incorrectly interpreted as -1 which is an error code. If you use anything but 0xFF it should work though.

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Writing to Uart
« Reply #7 on: July 19, 2016, 01:35:06 am »
Great that this will be solved, yes it seems that every thing else is working but in my case I need to send three 0xFF to notify the receiving part that my command is done.
So I have to wait for the fix  :)

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: Writing to Uart
« Reply #8 on: July 20, 2016, 02:05:18 am »
I have now verified that the new version solved this issue.

I could now both read and write to Uart
Like Like x 1 View List

plains203

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: [SOLVED] Writing to Uart
« Reply #9 on: July 20, 2016, 02:46:02 am »
Thanks for working this one through. I purchased one of those touchscreens you are using and I can see that this issue is related. The touch screen looks really good.
McGateway 0.6-360, 0.7-405
McModules 0.7-358
McStudio 0.7-894

kristofferis

  • Sr. Member
  • ****
  • Posts: 287
  • Location: Sweden
    • View Profile
Re: [SOLVED] Writing to Uart
« Reply #10 on: July 20, 2016, 02:49:59 am »
Ahh nice, yeah now it's possible to both send and receive commands from the touchscreen.

I have a module that updates the screen every minute and it has been running all night.