UART access

Solved
roberthartman's picture
roberthartman
Junior(0)

I'd like to use the Debug UART (UART2) on the AT&T IoT Starter Kit (2nd Gen) dev board to communicate with another board, and I'm using the iot_monitor demo application as a starting point for our own demo project. I can successfully do POSIX open and write to what I believe is the correct device. However I can only semi-successfully do a read, which seems to get messed up due to the login prompt presented by the system, as described in this forum link. When I use "screen" on my Mac to read from UART2, the following works fine ("12345" is printed on the Mac terminal):

#define UART2 "/dev/ttyHSL0"
int fd = open(UART2, O_RDWR);
char *str = "12345\n";
write(fd, str, strlen(str));

However, as stated above, the aforementioned login prompt conflicts with my reads. For example, if the below code is in a loop, the read call blocks, and when 2 characters are typed in the Mac terminal, read may or may not return, depending upon the state of the command prompt the deivce presents (depending upon whether the prompt is waiting for user or password or ???). Here's the read code:

char buffer[10];
memset(buffer, 0, sizeof(buffer));
int readResult = read(fd, buffer, 2);

Here's what I see in the Mac screen/terminal after restarting my application (commentary added after the fact). "apptcu" is the name of my application:

[ 151.287522] register GPIO(23) by apptcu is success.
[ 157.328090] i2c-msm-v2 78b7000.i2c: NACK: slave not responding, ensure its powered: msgs(n:2 cur:0 tx) bc(rx:1 tx:1) mode:FIFO slv_addr:0x5f MSTR_STS:0x0d1300c8 OPER:0x00000010
12345 // This is the output of my write, just after the open.

aa // I typed "aa", and my read does not read these bytes. This appears to be the prompt waiting for login/username

Password: // Typed "aa" for the second time, again my read does not read these bytes. This input appears to be treated like the password

aa // Typed "aa" the third time, and my read does indeed read these bytes, and my app proceeds thru its loop.

Login incorrect

D54A1 login:

D54A1 login: aa

Password:

aa

Login incorrect

// ... etc.

I'm really hoping there's a way to disable this login prompt, but guessing there is not. Is there some way I can reliably read UART2? It seems that UART1 may not be available according to this link, which states "The WNC module firmware limits UART1 to predefined system functions for: High Speed Data Transfer "/. Any help is appreciated!

roberthartman's picture
roberthartman
Junior(0)

I apologize for the lack of formatting above. Somehow things got messed up, and the forum thinks I am spamming it when I attempt to edit the post!

jflynn129's picture
jflynn129
Moderator(2)

Rob, I'm sorry to say that there is no way to utilize UART2 that I am aware of.  We have asked WNC about access this UART and was told that it is only availabel to be used for modem debug by WNC.  Apparently, it was defined this way in the kernel build by WNC.  They stated that it would invalidate their PTCRB certification if they allowed its use so we were told not to use it.   This is also how we descrbied it in the Hardware user manual in section 3.4.4

Jim Flynn

 

roberthartman's picture
roberthartman
Junior(0)

Jim, thanks for the response. Is there a contact at WNC that can help us figure out how to modify the kernel build? I can see how the datasheet alludes to this limitation, but in my opinion it's a little vague, open to interpretation, and could have been stated a little more explicitly. Any contact info or help you can provide would be really helpful, since I'm running out of time to get this working. Thanks again.

jflynn129's picture
jflynn129
Moderator(2)

Rob, I am checking with WNC as soon as I hear back I'll forward the response/contact info.

roberthartman's picture
roberthartman
Junior(0)

Jim, we're starting to look at using SPI via the PMOD header... But in the meantime, I'm wondering about UART1... I'm guessing it is also unavailable, but I thought I should ask to make sure. "The WNC module firmware limits UART1 to predefined system functions for: High Speed Data Transfer". Is there a way I can use UART1?

jflynn129's picture
jflynn129
Moderator(2)

What i've heard from WNC is that they are investigating enabling the UARTs.  In the mean time, look at https://www.maximintegrated.com/en/products/interface/controllers-expand... which is an I2C/SPI UART interface.  Perhapse it is possible to talk with your devices via I2C/SPI on the SK2 side while sill having UART access for the connected device.

 

roberthartman's picture
roberthartman
Junior(0)

Jim, just a quick update - we've been corresponding with a local rep of FAE or whatever on the possibility of WNC opening up UART2, and so far haven't gotten anything concrete on that. As a result I've switched gears to using SPI via the PMOD header. So far this is meeting our needs. I started out attempting to use the hwlib SPI driver, similar to how the MAX31855 example code does, but for whatever reason I had trouble getting that working (I believe something was wrong on my end), so I've switched over to using the Linux spidev driver. At this point things are looking good.

jflynn129's picture
jflynn129
Moderator(2)

Thanks for the feedback.  WNC has been working to enable the UART but I don't think the SW has been released yet.  As soon as I hear it is, I'll make sure you get notified. Good to hear that the spidev driver is working for you.

Hi,

I have an application that I've developed for a Linux environment that I would like to get running on the Iot Starter Kit 2nd Gen.  The application and
dependent libraries build and run nicely on the board.  I've got a missing piece though, the UART.  I'd like some advise on how best to go about creating
an RS232 connection between the Iot Starter Kit 2nd Gen and another device.  I see this discussion of the two UARTs and I've looked through the references in
the documentation; I remain unsure how to proceed.  What is the status of application access to UART1 or UART2?  Would a USB to serial adapter be a
possability (I'm thinking USB to serial wouldn't work if I want to continue to use adb since we cannot have two hosts on USB)?  If it makes a difference, here
is my board's version information:

WNC> wncinfo
 WNC Information
              WNC Model: M18Q2FG-1
           Apps Version: OE_v01.00.174241
       Firmware Version: M18Q2_v12.09.170553
            MAL Version: malm_75_v02.01.1710180
         Operating Mode: 0-Online
                     IP: 10.34.39.178
                  ICCID: 89011703278113078862
                   IMEI: 014814000339109
                   IMSI: 310170811307886
                 MSISDN: <null>

Thanks for any pointers,

David

jflynn129's picture
jflynn129
Moderator(2)

replied via PM.