question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I use Modbus Slave to simulate slave, but I get reverse data. image Slave Log

000070-Rx:00 00 00 00 00 06 01 03 00 00 00 0A 
000071-Tx:00 00 00 00 00 17 01 03 14 01 09 01 83 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
000072-Rx:00 01 00 00 00 06 01 03 00 00 00 0A 
000073-Tx:00 01 00 00 00 17 01 03 14 01 09 01 83 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

Master code

        static void Fluent()
        {
            var client = new ModbusTcpClient();
            client.Connect(IPEndPoint.Parse("127.0.0.1:502"));
            var d1 = client.ReadHoldingRegisters<ushort>(1, 0, 10);
            Console.WriteLine(string.Join(";", d1.ToArray().Select(BitConverter.GetBytes).Select(c => BitConverter.ToString(c)).ToArray()));
            Console.WriteLine(string.Join(";", d1.ToArray()));

            var d2 = client.ReadHoldingRegisters(1, 0, 10);
            Console.WriteLine(BitConverter.ToString(d2.ToArray()));
            Console.WriteLine(string.Join(";", d2.ToArray()));

            client.Disconnect();
        }

Master output

01-09;01-83;00-00;00-00;00-00;00-00;00-00;00-00;00-00;00-00
2305;33537;0;0;0;0;0;0;0;0
01-09-01-83-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
1;9;1;131;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0
Slave send Master output
265(0x0109) 2305(0x0901)
387(0x0183) 33537(0x8301)

I tested it in NModbus, it works correct. NModbus code

        static void NModbus()
        {
            using var tcpClient = new TcpClient();
            tcpClient.Connect(IPEndPoint.Parse("127.0.0.1:502"));
            using var client = new ModbusFactory().CreateMaster(tcpClient);
            var d = client.ReadHoldingRegisters(1, 0, 10);
            Console.WriteLine(string.Join(";", d.Select(BitConverter.GetBytes).Select(c => BitConverter.ToString(c)).ToArray()));
            Console.WriteLine(string.Join(";", d));
        }

NModbus output

09-01;83-01;00-00;00-00;00-00;00-00;00-00;00-00;00-00;00-00
265;387;0;0;0;0;0;0;0;0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Apollo3zehncommented, Aug 6, 2020

Sorry for my late reply. I have released a new version that allows to specify the data layout (big-endian vs little-endian).

Example:

var client = new ModbusTcpClient(..., ModbusEndianness.BigEndian);

When you specify this layout, all data will be reversed automatically.

I´ll close this issue for now as it should be resolved. If you have further issues, feel free to reopen it.

0reactions
Apollo3zehncommented, Apr 4, 2020

Thanks for your feedback. Unfortunately I don’t have much time right now, but I`ll try to fix it next week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flip Data in Excel | Reverse Order of Data in Column/Row
Sometimes, you may have a need to flip the data in Excel, i.e., to reverse the order of the data upside down in...
Read more >
How to flip data in Excel columns and rows (vertically ...
In situations when you need to reverse the data order in a column arranged alphabetically or from smallest to largest, you can obviously...
Read more >
Reverse Data in Excel
How to flip data upside down i.e. reverse data in Excel. An efficient method to make rows reverse order without using VBA or...
Read more >
Reverse Data Management
Reverse transformations modify the source data rather than generate a new target data instance. Some examples of reverse transformations include updates through ...
Read more >
3 Easy Ways to Flip Data in Excel (Reverse the ... - YouTube
In this video, I will show you how to flip the data in Excel (i.e.., reverse the order of the data in rows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found