> It seems CDC requires the serial port to be opened before any communication.
> There isn't any kind of buffer: if I put the send_slip_packet() while CDC
> status isn't ok, I don't receive anything. And when I put it before the
> forever loop, while device is being configured (CDC status becomes OK at
> this time), it's been called but I don't receive anything either later. Is
> it right to say there's no buffering when using CDC ?
I don't know much about the USB lib or if there is a buffer. However,
with normal serial communications, data can still be sent out even if
the port is not open on the PC side. Data will be lost. USB serial
should act the same.
> Now, about SLIP comms, here's what I have:
>
> 1. I connect to the device (/dev/ttyACM0) using a python script.
>
> 2. since the port is opened, CDC status is OK and I receive a SLIP packet.
> In sample, test_data = {1,2,3,0xC0,5,6,0xDB,8,9,10}, and I receive: {0xc0,
> 1, 2, 3, 0xdb, 0xdc, 5, 6, 0xdb', 0xdd, 8, 9, 0xc0}.
> - So far so good, but: why does it start with a SLIP END char ?
It may be a good idea for you to test the library with a normal serial
port before trying USB, this way you will know the expected data. It
starts with SLIP END char because it is good practice to send/receive
a SLIP END character before each packet (per the RFC). This will flush
any bad data on the serial line so it does not get into your packet.
So, if you send two SLIP packets, you will get a 3rd packet between
them with a size of 0 bytes that gets ignored.
> 3. now I send back the same packet: {1,2,3,0xC0,5,6,0xDB,8,9,10}. Since the
> code is supposed to echoed the data back, I would have expected to
> get {0xc0, 1, 2, 3, 0xdb, 0xdc, 5, 6, 0xdb', 0xdd, 8, 9, 0xc0}, as before.
> But I have: {'A', 'T', '+', 'G', 'C', 'A', 'P', '\r', '\n', 'A', '\x00',
> '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
> '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x01', '\x02',
> '\x03', '\xc0', '\x05', '\x06', '\xdb', '\x08', '\t'}
> - packet size is 36, which is greater than MTU (10).
> - I really don't understand where those first chars comes from
> - it seems there's some kind of padding with 0x00
>
> 4. If I send the packet again, I now receive {'\x01', '\x02', '\x03',
> '\xc0', '\x05', '\x06', '\xdb', '\x08', '\x09'}
> - why SLIP END appears again in the middle, after 3 ?
Don't know. there shouldn't be any '\x00' padding. Maybe you need that
END CHAR at the beginning to flush bad data?? After a quick look at
the data you are sending back, it appears that you did not encode it
first. Try sending back {0xc0,1, 2, 3, 0xdb, 0xdc, 5, 6, 0xdb', 0xdd,
8, 9, 0xc0}. You should get back your original decoded message.
> Do you have any idea what I'm doing wrong ? Attached is my sample...
I'll try your sample on windows when I get a chance. I haven't had a
chance to look at your code yet, these are all just quick suggestions.
> And, does anyone know a program under Linux to talk in SLIP ?
Google "slip serial terminal". I found
http://www.opend.co.za/software/terminal/index.htm,
but it seems that it is for windows. Will it work under Wine?
I used slattach to connect my slip networking, but it is not a serial
terminal program. I am interested to know weather it would encode/
decode silp data for you.
slattach -p slip -s 115200 /dev/ttyS0 &
Matt.