自定义RS485协议(Custom RS485 Protocols)
我正在为分布式系统中的串行通信编写一个简单的多点RS485协议。 我正在使用一个可寻址的模型,其中从设备被给予一个20ms的窗口来响应。 主uC轮询连接的设备以进行更新,并相应地做出响应。 我使用了校验和并采取必要的超限预防措施,以确保连接的设备不会响应格式错误的消息。 事实证明,这种方法在大约99%的情况下都有效,但如果在通信会话期间引入了新设备,则会丢失数据包。 插入新设备“热”将对从设备监控的信号产生负面影响,如果只是在极短的时间内。 我是工程的软件方面,但是如何在不尝试重新创建TCP的情况下缓解这种情况? 我们使用轮询模型,因为它很快并且对我们的应用程序来说工作得很好,不需要RTOS功能。 我在每个cpu上有很多周期,用基本术语来思考。
I am writing a simple multi-drop RS485 protocol for serial communications within a distributed system. I am using an addressable model where slave devices are given a window of 20ms to respond. The master uC polls the connected devices for updates and they respond accordingly. I've employed checksums and take the necessary overrun precautions to ensure that connected devices will not respond to malformed messages. This method has proved effective in approximately 99% of situations, but I lose the packet if a new device is introduced during a communication session. Plugging in a new device "hot" will have negative effects on the signal being monitored by the slave devices, if only for an extremely short time. I'm on the software side of engineering, but how I can mitigate this situation without trying to recreate TCP? We use a polling model because it is fast and does the job well for our application, no need for RTOS functionality. I have an abundance of cycles on each cpu, think in basic terms.
原文:https://stackoverflow.com/questions/3605979
最满意答案
简单地将数据连接在一起,连接到
stops
两次开始和结束停止,并加入stop_times
两次开始和结束stop_times,
我唯一不确定的是direction_id
来自哪里。
尝试以下查询。
在查询的最后,您可以指定start_s.stop_id
和end_s.stop_id
,它代表您查询数据的两个站点。SELECT t.trip_id, start_s.stop_name as departure_stop, start_st.departure_time, direction_id as direction, end_s.stop_name as arrival_stop, end_st.arrival_time FROM trips t INNER JOIN calendar c ON t.service_id = c.service_id INNER JOIN routes r ON t.route_id = r.route_id INNER JOIN stop_times start_st ON t.trip_id = start_st.trip_id INNER JOIN stops start_s ON start_st.stop_id = start_s.stop_id INNER JOIN stop_times end_st ON t.trip_id = end_st.trip_id INNER JOIN stops end_s ON end_st.stop_id = end_s.stop_id WHERE c.monday = 1 AND direction_id = 1 AND start_st.departure_time > "00:00:00" AND start_st.departure_time < "23:59:59" AND r.route_id = 1 AND start_s.stop_id = 42 AND end_s.stop_id = 1
我尝试从这个链接查找GTFS结构示例,我在
direction_id
上找不到任何内容指定停止名称而不是
AND start_s.stop_id = 42 AND end_s.stop_id = 1
只需使用AND start_s.stop_name = 'Garrison' AND end_s.stop_name = 'Grand Central'
simply joining data together, joining to
stops
twice for start and end stop and joining tostop_times
twice for start and end stop_times,
the only thing i am unsure about is wheredirection_id
comes from.
try the below query.
At the very end of the query, you can specifystart_s.stop_id
andend_s.stop_id
which represents the two stops you're querying data about.SELECT t.trip_id, start_s.stop_name as departure_stop, start_st.departure_time, direction_id as direction, end_s.stop_name as arrival_stop, end_st.arrival_time FROM trips t INNER JOIN calendar c ON t.service_id = c.service_id INNER JOIN routes r ON t.route_id = r.route_id INNER JOIN stop_times start_st ON t.trip_id = start_st.trip_id INNER JOIN stops start_s ON start_st.stop_id = start_s.stop_id INNER JOIN stop_times end_st ON t.trip_id = end_st.trip_id INNER JOIN stops end_s ON end_st.stop_id = end_s.stop_id WHERE c.monday = 1 AND direction_id = 1 AND start_st.departure_time > "00:00:00" AND start_st.departure_time < "23:59:59" AND r.route_id = 1 AND start_s.stop_id = 42 AND end_s.stop_id = 1
I tried looking up GTFS structure example from this link and i couldn't find anything on
direction_id
To specify stop names instead of
AND start_s.stop_id = 42 AND end_s.stop_id = 1
just useAND start_s.stop_name = 'Garrison' AND end_s.stop_name = 'Grand Central'
相关问答
更多-
字符串按字典顺序排序。 '9:00'将在'11:00'因为对于字符串, '9'大于'1' 。 要解决此问题,您可能希望拆分':'并从值中创建整数: def sort_key(time): hour, minute = time.split(':') return int(hour), int(minute) arr = ['9:00', '9:40', '9:50', '11:00', '15:00', '18:00'] dep = ['9:10', '12:00', '11:20 ...
-
我想在名为arrival_time的字段中的两个时间范围之间进行查询(i want to query between two time ranges in a field called arrival_time)[2022-08-02]
尝试 { "query": { "range": { "arrival_time": { "gte": "13:00:00", "lte": "15:00:00" } ... -
我相信这会给你你想要的东西: SELECT arrival, departure, trip_id, stop_id, stop_headsign, route_id, headsign, stop_code, stop_name, stop_lat, stop_lon, count(*) FROM temp GROUP BY arrival, departure, trip_id, stop_id, stop_headsign, route_id, headsign, stop_code, stop_na ...
-
如果我做对了,你想: 默认情况下,将当前日期设置为到达日期,将第二天设置为出发日期 更改到达日期时更新出发日期仅在更高时更新 我的解决方案是这样。 首先,你必须通过放置onchange="changedDate()"来捕获事件。 然后检查arrivalDate>departureDate和true是否为该日期,最后用下一个更新出发日期。 addDate(); function addDate() { date = new Date(); var month = date.getMonth() ...
-
GTFS查询列出两个停止名称之间的所有出发和到达时间(GTFS Query to list all departure and arrival times between two stop names)[2024-03-21]
简单地将数据连接在一起,连接到stops两次开始和结束停止,并加入stop_times两次开始和结束stop_times, 我唯一不确定的是direction_id来自哪里。 尝试以下查询。 在查询的最后,您可以指定start_s.stop_id和end_s.stop_id ,它代表您查询数据的两个站点。 SELECT t.trip_id, start_s.stop_name as departure_stop, start_st.departure_time, d ... -
如何在neo4j中从两种不同的关系中获得出发时间和到达时间(How to get departure time and arrival time from 2 different relation in neo4j)[2023-09-21]
再来一次: CREATE (a:Stop {name:'A'}), (b:Stop {name:'B'}), (c:Stop {name:'C'}), (d:Stop {name:'D'}), (a)-[:NEXT {distance:1}]->(b), (b)-[:NEXT {distance:2}]->(c), (c)-[:NEXT {distance:3}]->(d), (b1:Bus {id:1}) ... -
SQL查询 - 根据时间表获取到达和离开站点(SQL query - getting arrival and departure stations based on time table)[2022-05-08]
建立: CREATE TABLE STATION ( id NUMBER PRIMARY KEY, name VARCHAR2(20), city VARCHAR2(20) ); CREATE TABLE SERVICE ( train_number NUMBER PRIMARY KEY, train_name VARCHAR2(20) ); CREATE TABLE ROUTE ( id NUMBER PRIMARY KE ... -
你有正确的想法,但你应该一起加入桌子。 尝试这个: SELECT DISTINCT r.route_short_name FROM stop_times st INNER JOIN trips t ON t.trip_id = st.trip_id INNER JOIN routes r ON r.route_id = t.route_id WHERE st.stop_id =
; 为了获得良好的性能,请确保将stop_times编入索引以允许通过停止ID ... -
pcap (数据包捕获)API应该允许您获取此信息。 这是一些示例代码: link 。 The pcap (packet capture) API should allow you to get this information. Here is some example code: link.
-
是的,虽然取决于您的应用程序,性能可能不是您期望的一切。 按照你的例子,让我们呼叫停止A 原点停止并停止B和C 连接停止 。 然后,为了建立一组连接的止损,我们想要找到所有止损 与原点停止共享旅行,和 在原点停止之前或之后立即访问该共享行程。 我们可以使用stop_times表的stop_sequence字段来测试第二个条件。 试试这个SQL: SELECT DISTINCT stops.id, stops.code, stops.name FROM stop_times AS origin_stop ...