CAN socket - handle not ACK - can-bus

I'm trying to test getting the ACK bit from a CAN network. My system has an RPI 4, PICAN DUO and transceivers to other CAN nodes. When the RPI and the other node are both connected, all is well and I'm getting 2 way communication.
When the RPI is by itself, I'm sending a Message and should receive an Error, indicating no ack has occurred, but I'm getting nothing.
Configuration:
can.interface.Bus(interface="socketcan", receive_own_messages=True, channel="can1", bitrate=500000, err_reporting=True)

You do not deal directly with ACK, but you can be notified when such event happens. All relevant info can be found in Linux SocketCAN documentation.
If you want implementation details, at this link you can find my hlcanerrdump tool which can parse and show all errors on CAN bus (including NoAck), and hlcanerrsim tool for simulating all kinds of CAN bus errors. Study the source code and you will understand how to achieve what you want.

Related

How to read from can input port in can bcm mode?

I am writing code for a Debian 11 Linux platform that needs to control multiple 3.5kW motors using an intelligent motor controller. I started using CAN_RAW sockets since I was familiar with them from past work. However, I discovered that the timing requirements on sending certain tx messages (1200-2000 identical messages spaced at 5ms intervals) required me to use CAN_BCM mode and let the CAN hardware do the work. The motor controller doesn't reply to any of the TX_SETUP messages, it only replies to the individually sent TX_SEND messages.
The transmit side works great, I can send single or multiple messages. I don't know how to receive messages in BCM mode. I only need to receive the reply messages from the TX_SEND messages above. What setup do I need to do (if any) to receive all messages that are sent back to my Linux board? A good example is worth everything.
Thanks!
I tried calling read() and recvfrom() but I need some good documentation or an example.

How to write an HL7 Ping Script?

I am currently trying to write a script that could conduct an "HL7 Ping" but I am still new to HL7 and not 100% sure how I could do that. I am trying to build out a health check for my HL7 enabled devices and have come up fruitless. I've seen solutions like testing the port and such; however, this does not fulfill my goal. I want to send a message:
MSH|^~\&|MONITORINGPING||||||ADT^A01|
And get some sort of ACK back to confirm whether the service is up and running. Does anybody out there know the answer or know where I could go to get it?
There is no such a thing as "ping" or "health check" on HL7 or MLLP level. Please refer to this answer for more details about MLLP.
The message you are sending
MSH|^~&|MONITORINGPING||||||ADT^A01|
is just one segment of ADT message. This is not a valid message. If you want the ACK in response, you should send full and valid ADT (or any other) message. Although, some HL7 Listeners may send NAK for such message; I will recommend do not rely on that.
On TCP level, you may simply ping the IP or alternatively you can telnet IP and port.
An ADT message is not appropriate to "ping" a remote system. The closest trigger event for what you're trying to do is probably NMD^N02 (Application Management Data Message). But you'll find that trigger event isn't supported by most real world applications.

Why is Quectel BG96 stuck at trying to register the CS service?

I'm trying to get a BG96 up on to the Verizon network to do some MQTT communication.
The Quectel docs say to follow the TCP/IP AT command state machine before doing the MQTT commands. Makes sense to me.
I have an activated SIM card with an M2M data plan for this device, but it never seems to get past the second step, registering for CS service. It gives status of 2, "Not registered, but MT is currently trying to attach or searching an operator to register to." I checked the antenna and moved to a location closer to windows, but no luck.
at
OK
at+cpin?
+CPIN: READY
OK
at+creg?
+CREG: 0,2
OK
The same status is returned for the PS services, FWIW, but that's not surprising I think because the Quectel BG96 AT docs say you must register CS service first.
Any idea why a BG96 would be stuck at status 2 for at+creg??

Sending MQTT messages to Orion Context broker

I have a relatively simple switch that sends data whenever the button is pressed (either 1 or 0). The message protocol it uses is MQTT. It is connected to Mosquitto via Wi-Fi and successfully sends data to it (i am able to see it using mosquitto_sub -v -t "#". However, I would like to be able to send this data to Orion Context Broker and then receive it using REST commands and store it using Fiware-Cygnus afterwards.
the topic that sensor publishes messages to is tt/sergo/demo/sw
the name of the sensor presented in mosquitto_sub when sensor is first connected: DMS-A01
the IP - address of sensor: 192.168.0.108
I have installed Iot-Agent UL, which is working, but I don't know how to make it listen to the specific sensor that sends data to Mosquitto.
I read the manuals but either missed something or did not find the solution to my problem.
I tried using the manual below, but could not apply it to my problem.
Connecting "thing" to Fiware
Thank you in advance, stack overflow community.
Before sending measures you need to do a provision operation for the device using the IOTA-UL API. That provision operation "creates" the device in the IOTA-UL and map it with the corresponding entity at CB. Then, you can start sending measures using MQTT.
You can have a look to this piece of documentation for more detail.

How do I increase the priority of a TCP packet in Delphi?

I have a server application that receives some special TCP packet from a client and needs to react to it as soon as possible by sending an high-level ACK to the client (the TCP ACK won't suite my needs).
However, this server is really network intensive and sometimes the packet will take too long to be sent (like 200ms in a local network, when a simple server application can send it in less than 1ms).
Is there a way to mark this packet with a high-priority tag or something like that in Delphi? Or maybe with the Win32 API?
Thanks in advance.
EDIT
Thanks for all the answers so far. I'll add some details. My product has the following setup: there are several devices that are built upon vehicles with WIFI conectivity. When they arrive at the garage, those device connect to my server and start to transmit data.
Because of hardware limitations, I implemented a high-level ACK to make the device aware that the last packet arrived successfully (please, don't argue about this - the data may be broken even if I got a correct TCP ACK). However, if I use my server software, that communicates with a remote database, to issue this ACK, I get very long delay (>200ms). If I use an exclusive software to do this task, I get small latencies (<1ms). So, I was imagining if I could just tell Windows to send those special packets first, as it seems to me that this package is getting delayed so the database ones can get delivered.
That's the motivation behind my question.
EDIT 2
As requested: this is legacy software and I'm using the legacy dclsockets140.bpl package and Delphi 2010 (14.0.3593.25826).
IMO it is very difficult to realize this. there are a lot of equipment and software involved. first of all, if you communicate between 2 different OS's you got a latency. second, soft and hard firewalls, antiviruses, everything is filtering/delaying your package.
you can try also to 'hack' the system(this involve some very good knowledge on how the frames/segments are packed/send,flow control,congestion,etc), either by altering it from code, either by using some tools like http://half-open.com/ or others.
In short, passing MSG_OOB flag to the send function marks the data as "urgent". Detailed discussion about the OOB in the context of Windows Sockets implementation specifics is available here.

Resources