Differentiate between RX and TX messages in a CAN DBC - can-bus

I want to differentiate between rx and tx CAN-messages from a DBC but can't find any difference, when I open it with notebook. As anyone a idea if they can be identified in a DBC?

The DBC Format is described here and here.
The sender is specified on the same line as the message definition like so:
BO_ <CAN-ID> <MessageName>: <MessageLength> <SendingNode>
While the receiver is specified on the signal line:
SG_ <SignalName> [M|m<MultiplexerIdentifier>] : <StartBit>|<Length>#<Endianness><Signed> (<Factor>,<Offset>) [<Min>|<Max>] "[Unit]" [ReceivingNodes]
So for the following definition, IO is the sending node while DBG is the receiving node (in other word this is a Tx-Message for IO and an Rx-Message for DBG):
BO_ 500 IO_DEBUG: 4 IO
SG_ IO_DEBUG_test_unsigned : 0|8#1+ (1,0) [0|0] "" DBG

Related

pyserial issues with high baudrate FTDI

I have the following setup:
A FPGA sending out data on UART at a baudrate of 3Mbps. The data transmitted is a chunk of 1024 bytes sent at a variable periodicity ranging from 20ms to 200ms. (So even in the worst case, datarate is far from 3Msps)
A FTDI 232RG
A piece of python running on my computer (Windows), doing basically : opening a COM port with pyserial, 3Msps, polling the in_waiting until it reaches the size of a packet (1024 bytes), formatting the packet received and print it on the screen
The script works well for low repetition frequency, but I face issues with higher repetitions (typically 20ms). When the periodicity in 20ms I eventually end up getting a buffer overflow somewhere before the in_waiting. I checked the timing of my python loop and it takes about 4ms. So it looks like there is something upstream (in the FTDI or Windows) that feeds the pyserial buffer with more than one packet within the 4ms following a packet.
I tried changing the FTDI latency in the driver (from 16ms default down to a few ms) but it does not seem to help.
I am currently clueless about what is happening. Would you have any advice about how to understand better what is happening?
Thanks for your help!
You could create a "loop" between TX and RX and run the following code (tested with a FT2232H, so mostlikely you need to change the identifier string):
import time
import serial
import serial.tools.list_ports
print([(x[0],x[2]) for x in serial.tools.list_ports.comports()])
port = [x[0] for x in serial.tools.list_ports.comports() if "FT4Q1LJFB" in x[2]][0]
ser = serial.Serial(port,12000000)
while True:
t0 = time.time()
counter = 0
for i in range(1000):
ser.write([1]*3000)
recv = ser.read(ser.inWaiting())
delta_t = time.time() - t0
counter += len(recv)
print(counter / delta_t)
For me the following output is shown
[('COM7', 'USB VID:PID=0403:6010 SER=FT4Q1LJFA'), ('COM8', 'USB VID:PID=0403:6010 SER=FT4Q1LJFB')]
0.0
0.0
0.0
0.0
96787.81184093593
1201991.0268273412
1201197.0857713912
1201166.9350959768
1201445.4072856384
You will notice that it is 0.0 in the beginning. This is because I connected RX and TX after starting the program resulting in a ramping up of the received bytes. This is the "default" mode meaning 8 bits + 1 start bit + 1 stop bit = 10 bits per word which explains why "only" 1.2 Mbytes per second are transmitted.

Communication between Erlang and c program

When erlang module communicates with a c program via a port it sends a packet to the c program my question is when i create a port using this configuration
Port = open_port({spawn, ExtPrg}, [{packet, 2}]).
what are the parameters sent in the packet ?
what is the length of each parameter?
Erlang module and C program communicate via stdin and stdout by sending byte stream(sequence of bytes).
Creating a port with
Port = open_port({spawn, ExtPrg}, [{packet, N}]).
(valid values for N are 1,2,4)
tells erlang that the packets sent will be in this format :
N bytes : data length of the packet (we can conclude the data length)
data length bytes : data

Detect disconnected socket?

I have client iOS app that connects to server.
It uses non blocking socket.
int fl;
fl=fcntl(s,F_GETFL,0);
fcntl(s,F_SETFL, fl | O_NONBLOCK);
int set = 1;
setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
If there is no data then -1 returned by read
If it is disconnected then 0 returned by read
But it is not always true. Sometimes connection is lost but -1 is returned.
Is there something like eof to detect ?
0 is the EOF. If there is an error -1 is returned by read, and you should look at errno to see what it is. The only reliable way to detect a dropped connection in TCP is by writing to it at least twice.

saving some selected flows in a separate pcap file using wireshark

i am using wireshark Version 1.6.4. i have following questions regarding the stream numbers in wireshark :
1) why is it that tcp streams use numbers while udp streams don't ? (when i do "follow tcp stream" it shows say "tcp.stream eq 2" but it is not the same when i do "follow udp streams)
2) i go to conversations and i want to save some selected flows (tcp or udp or both) in a separate pcap file. i thought of using some filter like (tcp.stream eq 4 || tcp.stream eq 2 || udp.stream eq 1) if i want to save 2 tcp flows for these two streams and one udp flow in a separate pcap file. Now the issue with this approach is that conversation window doesn't show up the stream no's & further udp streams don't have the stream no. Also i need to go to conversation window first to see which tcp flows to save (say i want to save some flows having maximum bytes exchange) and then select that flow to see its stream number and so on for other flows as well. This is very inconvenient and time consuming. Is there some better way to do this.
any help will be greatly appreciated. thanks a lot.
2 Conversations Window
-right-click a tcp or udp stream and select "Prepare a Filter" | "Selected" | "A <-> B"
You can see the Display Filter in the Filter Toolbar
-right-click another tcp or udp stream and select "Prepare as Filter" | "... or Selected" | "A <-> B"
-right-click the last tcp or udp stream and select "Apply as Filter" | "... or Selected" | "A <-> B"
Next you can save those 3 streams in a separate capture file.

Printting on dot matrix printer with only Tx, Rx and Ground

My hardware communicate with PC serial port using Tx, Rx and ground lines for sending and receiving data, I wrote a program which can send some text to PC via serial line, now I wanted to alter it in such a way that I should be able to print that data on dot matrix printer which has a serial port.
I am using an Epson LQ 1150 dot matrix printer which has a db25 serial port. I tried connecting in following manner and sent data over serial line, the printer prints some garbage character and hangs.
Tx = Rx
Rx = Tx
Ground = Ground
I tried searching other posts explaining(db9-M to db25-F) :
Receive Data (RxD) 2 = 2 Transmit Data (TxD)
Transmit Data (TxD) 3 = 3 Receive Data (RxD)
Data Terminal Ready (DTR) 4 = 6 Data Set Ready (DSR)
System Ground (SG) 5 = 7 System Ground (SG)
Data Set Ready (DSR) 6 = 20 Data Terminal Ready (DTR)
Clear To Send (CTS) 8 = 4 Request To Send (RTS)
But I don't have DTR, DSR,and CTS. Is there any way I can make it possible using only 3 lines i.e. Tx, Rr and ground?

Resources