RE: Testing phonet

2013-05-07 Thread Andrzej Pietrasiewicz
On Wednesday, May 01, 2013 1:53 PM Daniele Forsi wrote:
 2013/4/30 Andrzej Pietrasiewicz:
 
  As I already wrote I am now stuck with sending correct data, so that
 when
  I sendto() from host I can recvfrom() on device (or vice versa).
 
 payload data doesn't matter so you don't need my dumps, maybe you are
 using the same address on both sides of the link or you are sending to
 the wrong address or the route isn't set up correctly
 

This is how I set up the host and the device, using the tools from
Rémi (http://gitorious.org/meego-cellular/phonet-utils/trees/master):

Device:
$ ./phonet -a 0x6c -i upnlink0
$ ./phonet -l -i upnlink0
  phonet addr: 6c
$ ./pnroute add 0x10 upnlink0
$ ./pnroute
 10 upnlink0
$ ifconfig upnlink0 up

Host:
$ ./phonet -a 0x10 -i usbpn0
$ ./phonet -l -i usbpn0
  phonet addr: 10
$ ./pnroute add 0x6c usbpn0
$ ./pnroute add 0x10 usbpn0
$ ./pnroute
 10 usbpn0
 6C usbpn0
$ ifconfig usbpn0 up

I attach the test program I use.
So far I have learnt that if I do

$ ./pnxmit -a 0x10 -s 0x6c

on the host, I can see that on the device the pn_rx_complete
(drivers/usb/gadget/f_phonet.c) is called, then netif_rx
(net/core/dev.c), then packet_type-func [phonet_rcv]
(net/phonet/af_phonet.c). The phonet_rcv fails at

if ((len  skb-len) || pskb_trim(skb, len))
goto out;

with len=61182 and skb-len=10.

The len looks suspicious, but I don't know why it is set to
such a large value.
In consequence NET_RX_DROP is returned from phonet_rcv,
so I assume no client will ever be able to recvfrom a socket.

Any ideas?

Andrzej


pnxmit.c
Description: Binary data


Re: Testing phonet

2013-05-01 Thread Daniele Forsi
2013/4/30 Andrzej Pietrasiewicz:

 As I already wrote I am now stuck with sending correct data, so that when
 I sendto() from host I can recvfrom() on device (or vice versa).

payload data doesn't matter so you don't need my dumps, maybe you are
using the same address on both sides of the link or you are sending to
the wrong address or the route isn't set up correctly

I'm attaching a test program that works with my phone but this is only
the host part because I don't know how to set up the device part, can
you share the details of your setup?
According to Documentation/networking/phonet.txt it should be possible
to do both parts on the same machine, that would test only the phonet
module and not cdc_phonet (Each socket [...] can send and receive
packets with any other peer).

--
Daniele Forsi
/*

  G N O K I I

  A Linux/Unix toolset and driver for the mobile phones.

  This file is part of gnokii.

  Gnokii is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  Gnokii is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with gnokii; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Copyright (C) 2010, 2013 Daniele Forsi

  This is a test for accessing the phone via the phonet Linux kernel module.

*/

#include sys/socket.h
#include linux/phonet.h
#include stdio.h
#include errno.h
#include string.h
#include unistd.h

/* from gnokii's include/links/fbus-common.h */
#define FBUS_DEVICE_PHONE 0x00

int test(int fd)
{
	struct sockaddr_pn addr = { .spn_family = AF_PHONET, .spn_dev = FBUS_DEVICE_PHONE };
	unsigned char req[] = {0x03, 0x15, 0x01}; /* addr.spn_resource = 0x1b get product name */
	char *port = usbpn0;
	unsigned char buf[1024];
	ssize_t len;
	int i;

	if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, port, strlen(port))) {
		perror(setsockopt);
		return 1;
	}

	addr.spn_resource = 0x1b;
	if (sendto(fd, req, sizeof(req), 0, (const struct sockaddr *)addr, sizeof(addr)) == -1) {
		perror(sendto);
		return 1;
	}

	len = recvfrom(fd, buf, sizeof(buf), 0, NULL, NULL);
	if (len == (ssize_t)-1) {
		perror(recvfrom);
		return 1;
	}

	for (i = 0; i  len; i++)
		printf(%02x , buf[i]);
	printf(\n);

	return 0;
}

int main(int argc, char *argv[])
{
	int fd, error;

	fd = socket(PF_PHONET, SOCK_DGRAM, 0);
	if (fd == -1) {
		perror(socket);
		return 1;
	}
	error = test(fd);
	close(fd);

	return error;
}


Re: Testing phonet

2013-04-30 Thread Daniele Forsi
Hello Andrzej, I removed people from CC

 On Monday, April 29, 2013 6:30 PM Daniele Forsi wrote:

 I can provide the OP with frames captured from a real phone when talking
 with gnokii


 You mean some kind of dump? What can it be useful for? Comparing the
 messages
 sequence to that of conversation with a real hardware? Simulating
 conversation
 with a real hardware without the hardware?

both: you can compare the recorded conversation if you have the
hardware or replay it without the hardware

 How can I get it from you?

tell what you want to test and what kind of dump you can use and I'll
see if I am able do it

--
Daniele Forsi
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Testing phonet

2013-04-30 Thread Andrzej Pietrasiewicz
On Monday, April 29, 2013 3:48 PM Rémi Denis-Courmont wrote:
 Le lundi 29 avril 2013 15:06:17, Sebastian Andrzej Siewior a écrit :
  In Documentation/networking/phonet.txt are few snippets how to open
  SOCK_DGRAM and PN_PROTO_PIPE. With this and read()/write() should work.
 
 Using datagram socket is possible to test IN and OUT. But you would first
 need to configure the network interface - on both the host and the gadget.
 For that you could use the old Phonet utilities:
 http://gitorious.org/meego-cellular/phonet-utils/trees/master
 

Thanks!

This was very helpful. The tools compile and seem to work both
on the host and on the device.

But I am now stuck with sending the right data over the link.
On a USB analyzer I can see one OUT transaction if I sendto()
from host to device, or one IN transaction if I sendto() from
device to host. The data packet in the transaction does contain
some data I can recognize, so I assume that the USB connectivity
itself works. But I don't know what to send in order for recvfrom()
to receive something.

Andrzej


--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Testing phonet

2013-04-30 Thread Andrzej Pietrasiewicz
On Tuesday, April 30, 2013 11:30 AM Daniele Forsi wrote:
 Hello Andrzej, I removed people from CC
 
  On Monday, April 29, 2013 6:30 PM Daniele Forsi wrote:
 
  I can provide the OP with frames captured from a real phone when
  talking with gnokii
 
 
  You mean some kind of dump? What can it be useful for? Comparing the
  messages sequence to that of conversation with a real hardware?
  Simulating conversation with a real hardware without the hardware?
 
 both: you can compare the recorded conversation if you have the hardware
 or replay it without the hardware
 
  How can I get it from you?
 
 tell what you want to test and what kind of dump you can use and I'll see
 if I am able do it
 

As I already wrote I am now stuck with sending correct data, so that when
I sendto() from host I can recvfrom() on device (or vice versa).

What I would like to test is to transmit any data, preferably both ways,
in order to see if the link works. Just that. The simpler the tool, the
better.
I would like best to have a small tool to run on both ends of the link to
verify the link is working.

When it comes to the dumps I would prefer a dump of the simplest
conversation possible between a host and a device, both ways.

Andrzej


--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Testing phonet

2013-04-29 Thread Felipe Balbi
Hi,

On Mon, Apr 29, 2013 at 01:38:08PM +0200, Andrzej Pietrasiewicz wrote:
 I have a question 
 
 @all in general and
 
 @Felipe and Rémi Denis-Courmont in particular
 
 Can you please give me a hint on how to test
 the phonet function, preferably without Nokia hardware?

I'll leave that to Rémi as I have no clue how to test that function :-p

-- 
balbi


signature.asc
Description: Digital signature


Re: Testing phonet

2013-04-29 Thread Sebastian Andrzej Siewior
On 04/29/2013 01:38 PM, Andrzej Pietrasiewicz wrote:
 Hello,

Hi,

 I have a question 
 
 @all in general and
 
 @Felipe and Rémi Denis-Courmont in particular
 
 Can you please give me a hint on how to test
 the phonet function, preferably without Nokia hardware?

In Documentation/networking/phonet.txt are few snippets how to open
SOCK_DGRAM and PN_PROTO_PIPE. With this and read()/write() should work.
However maybe Rémi posts a small client + server test tool that would
be way simpler :)

 
 Andrzej
 
 

Sebastian
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Testing phonet

2013-04-29 Thread Rémi Denis-Courmont
   Hello,



On Mon, 29 Apr 2013 13:38:08 +0200, Andrzej Pietrasiewicz

andrze...@samsung.com wrote:

 Can you please give me a hint on how to test

 the phonet function, preferably without Nokia hardware?



You should be able to test EP0 and EP OUT by connecting to a Linux USB

host. Host-side at least oFono used to support Phonet (not tried in a

year); maybe ModemManager or Gnokii would work too (not tried ever). EP IN

is going to be difficult without Nokia or Renesas modem. I fear you would

have to write your own C socket application to send Phonet packets over the

wire.



To my admittedly limited knowledge, the code was only ever used for Nokia

N900, N950 and N9 hardware, with obsolescent kernel versions. I would not

know if Renesas has any use for this.



-- 

Rémi Denis-Courmont

Sent from my collocated server
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Testing phonet

2013-04-29 Thread Rémi Denis-Courmont
Le lundi 29 avril 2013 15:06:17, Sebastian Andrzej Siewior a écrit :
 In Documentation/networking/phonet.txt are few snippets how to open
 SOCK_DGRAM and PN_PROTO_PIPE. With this and read()/write() should work.

Using datagram socket is possible to test IN and OUT. But you would first need 
to configure the network interface - on both the host and the gadget. For that 
you could use the old Phonet utilities:
http://gitorious.org/meego-cellular/phonet-utils/trees/master

 However maybe Rémi posts a small client + server test tool that would
 be way simpler :)

I may be wrong but I don't recall Nokia opensourcing any of these before 
Burning The Platforms. For all practical purposes, that code is lost.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Testing phonet

2013-04-29 Thread Daniele Forsi
2013/4/29 Rémi Denis-Courmont:

 Host-side at least oFono used to support Phonet (not tried in a
 year); maybe ModemManager or Gnokii would work too (not tried ever).

yes, gnokii supports Phonet with and without kernel the modules phonet
and cdc_phonet; the kernel modules only support USB, but without the
kernel modules gnokii supports Phonet over serial devices, USB with
libusb, native Bluetooth and native IrDA

 EP IN
 is going to be difficult without Nokia or Renesas modem. I fear you would
 have to write your own C socket application to send Phonet packets over the
 wire.

I can provide the OP with frames captured from a real phone when
talking with gnokii

--
Daniele Forsi
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Testing phonet

2013-04-29 Thread Andrzej Pietrasiewicz
On Monday, April 29, 2013 6:30 PM Daniele Forsi wrote:
 2013/4/29 Rémi Denis-Courmont:
 
  Host-side at least oFono used to support Phonet (not tried in a year);
  maybe ModemManager or Gnokii would work too (not tried ever).
 
 yes, gnokii supports Phonet with and without kernel the modules phonet and
 cdc_phonet; the kernel modules only support USB, but without the kernel
 modules gnokii supports Phonet over serial devices, USB with libusb,
 native Bluetooth and native IrDA
 
  EP IN
  is going to be difficult without Nokia or Renesas modem. I fear you
  would have to write your own C socket application to send Phonet
  packets over the wire.
 
 I can provide the OP with frames captured from a real phone when talking
 with gnokii
 

You mean some kind of dump? What can it be useful for? Comparing the
messages
sequence to that of conversation with a real hardware? Simulating
conversation
with a real hardware without the hardware?

How can I get it from you?

Thanks,

Andrzej



--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html