|
Dear all,
I am trying to implement modbus RTU with function code 1 . The code i have written implemented for function code 3 . i will get proper response for function code 3. When i implemented for function code 1 i am getting invalid checksum response error.
The crc function is working fine . I have checked modscan32, excel sheet of simplymodbus website.
Simply Modbus - Enron Modbus Function Code 01 - Read Boolean Variables[^]
[^]
On-line CRC calculation and free library[^]
CRC calculation code
unsigned int crc_fn(unsigned char *dpacket,unsigned int len)
{
unsigned int crc = 0xffff,poly = 0xa001;
unsigned int i=0;
for(i=0;i<len;i++)
{
crc^= dpacket[i];
for(j=0;j<8;j++)
{
if(crc & 0x01)
{
crc >>= 1;
crc ^= poly;
}
else
crc >>= 1;
}
}
return (crc);
}
Main function
void Serial_Data()
{
unsigned int address,crc1,crc2;
unsigned char length,i;
unsigned char Data_Len_Count;
unsigned char length1;
crc2=crc_fn(&rxbuf[0],6);
__delay_ms(10);
if((rxbuf[6]==(unsigned char)(crc2))&&(rxbuf[7]==((unsigned char)(crc2>>8))))
{
if(rxbuf[0]==Device_ID )
{
if(rxbuf[1]==READ_REG)
{
address=(((unsigned int)(rxbuf[2]<<8))+((unsigned int)(rxbuf[3])));
if(rxbuf[5]>=1)
{
length1=(rxbuf[5]<249)?(rxbuf[5]+7)/8:0X20;
length=(rxbuf[5]*1);
address=(address*1);
ser_data[0]=Device_ID ;
ser_data[1]=rxbuf[1];
ser_data[2]=length;
ser_data[3]=rxbuf[6];
ser_data[4]=rxbuf[7];
ser_data[5]=length1;
ser_data[6]=00;
ser_data[7]=00;
ser_data[8]=00;
ser_data[9]=00;
crc_data[0]=Device_ID ;
crc_data[1]=rxbuf[1];
crc_data[2]=length;
j=3;
for(i=address;i<((address+length));i++)
{
crc_data[j++]=ser_data[i+3];
}
crc1 =crc_fn(&crc_data[0],(length+3));
Serial_1_Send_byte(ser_data[0]);
Serial_1_Send_byte(rxbuf[1]);
Serial_1_Send_byte(ser_data[2]);
for(i=address;i<((address+length));i++)
{
Serial_1_Send_byte(ser_data[i+3]);
}
Serial_1_Send_byte((unsigned char)crc1);
Serial_1_Send_byte((unsigned char)(crc1>>8));
Serial_1_Send_byte(crc_msb);
Serial_1_Send_byte(crc_lsb);
for(i=0;i<30;i++)
{
Serial_1_Send_byte(0);
}
}
}
__delay_ms(5);
}
}
index=0;
rec_flag = 0;
My suspection is on Storing the values inside register and Sending them for CRC check.Because send response is going well, i get error while getting response.
|
|
|
|
|
You cannot use the same "logic" for function 01 as for function 03.
Function 01 deals with "coils"; i.e. bits.
Function 03 deals with "registers"; i.e. unsigned shorts.
The "sends" are the same except for the function code; on receive however, you get (bit equivalent) "bytes" back for function 01; and 2 bytes for each each register requested in function 03.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
There are lots of tools to create ISO image files on harddisk from a physical CD/DVD.
But are there drivers available (Windows 7 or 10) for reading a raw, physical CD/DVD, sector by sector (i.e. independent of any file system structure) into RAM, providing a driver interface so that software will see it as if it were a physical CD/ROM drive?
Alternately, but not as convenient for me: A driver making an ISO file appear as a physical drive rather than as an NTFS file. I don't need that permanent ISO image file, and waiting for it to be created will be a lot slower. (Actually, in my case, the RAM image could be built lazily: The application program could start immedately, and when the driver receives a request for a sector not yet read in, it could freeze the ongoing complete reading, serve the application by accessing the physical disk, and then return to the task of creating a RAM image of the complete disk.)
My PC, like most modern PCs today, has 16 Gbytes of RAM, so even a completely packed, two-layer DVD leaves between 6 and 7 GBytes RAM for other applications. If you need more, paging may throw out unused blocks to disk. Keeping a full DVD in RAM is perfectly realistic nowadays.
(In the good old days of DOS and 16+4 bit addressing, but RAM sizes were growing beyond 1 Mbyte, we did things like this with floppies: There was software to create a RAM disk in extended memory (who are old enough to remember LIM EMS? ). We created an 1.44 Mbyte RAM disk, copied in a entire floppy to it, in one go, track by track. If my memory is right, reading an entire track required two rotations, but after 154 rounds, for 77 tracks, the entire floppy was available thousands of times faster than reading the physical unit.
The problem today is not the ISO image file; I can write my own software to access every block in that image. Some other tools read from CD/DVD interfaces, rather than from the NTFS file system, or they provide other functions when reading from a physical drive. So I need a driver to fool them to believe that either an ISO file, or preferably, a RAM image of a disk, really is a physical drive, providing all those operations a physical drive offer, but at RAM speeds.
Which software is available to do give me that?
|
|
|
|
|
|
Maybe I wasn't clear enough.
I've got data on a DVD disk - or rather: A number of them. I've got an analysis program reading the data on the disks, but it will read from a physical disk only. It will not read from a disk file, neither on flash nor magnetic disks.
I do not produce the data; I receive and analyze them. It is more or less a one-time operation. Even if I could make an ISO file before I start the analysis, as soon as the analysis is done, I would delete the ISO file; I would not retain it, neither on a magnetic or flash disk.
RAM access is a lot faster than even flash disks, even with the OS caching disk blocks accessed. But more important: Creating an ISO image file on a flash or magnetic disk as a precursor to the analysis takes time. Especially if the driver would let you start working immediately after the DVD disk has been inserted, essentially reading the data sequentially in the most efficient way but if you refer to data not yet read in would put the sequential reading on hold to serve your request before continuing, the total time from start to completion could be a lot less.
Those alternatives in the article you link to will do half the job: Putting data in RAM. But the other half is having it appear not as an NTFS or FAT disk, but as a physical device that can be read as a raw DVD disk, below the file system layer. None of the 12 alternatives claim to mimic a physical DVD interface, and will not be accessible to an analysis program that reads from such interfaces only.
|
|
|
|
|
I'm still not "clear" then.
This tool will let you mount image files of hard drive, cd-rom or floppy, and create one or several ramdisks with various parameters. This all-in-one package includes the ImDisk Virtual Disk Driver (2.0.9), the DiscUtils library that extends the number of supported image file formats, and adds several GUIs and features.
(The "cd-rom" option includes "DVDs")
From there, there are virtual machines. If not, more "cpu" / threads.
Where you see obstacles, I see options.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
OK, so I have a DVD-ROM from which I can create an image file, aka "ISO file", residing on my harddisk / flash disk. This image file I can mount as RAMdisk so that I can access the files on that DVD-ROM as if it was a physical NTFS or FAT file system.
The text you quote states that the ISO file may be an image of a hard drive (with an NTFS or FAT file system), or a CD-ROM (with an ISO 9660 file system or derivatives) or floppy (with a FAT file system). Although the file system within that image file reside in RAM structures, read in from a single file created from a harddisk, CD-ROM or floppy, it will appear to file system requests as if it was a disk with an NTFS, ISO 9660 or FAT file system, with directories and format restrictions etc.
I see no indication whatsoever in the description that it allows direct access to physical sectors, or that it support device control for emulating physical drives. If it did, I am quite sure that it would be seen in the documentation.
Maybe ImDisk - in the good old "if it doesn't do what you want, modify it yourself" Open Source style - can be modified to appear as a physical CD/DVD drive with no implied file system structure, but providing a raw access to the sectors, and reacting sensible to all control signals that might be sent to a physical CD/DVD drive. If my task were to write drivers, I could probably do that. I did write a few driver in the DOS days; I never did for Windows.
If you have tried using ImDisk yourself, using some DVD/CD software accessing the RAM image as a physical drive - e.g. trying to burn files to the RAM disk as a CD-RW disk, ejecting the disk, responding to drive capabilites etc. - then you know better than I do. But then you probably would not refer to a description of functionality that is not what I am after.
|
|
|
|
|
Sorry, I just thought you were stuck in the weeds.
Last time I looked at sectors, it was using "Norton Utilities" on DOS x.x ... and I cannot even remember why.
I guess that's why my mind is going blank listening to you explain why you need to operate at the "sector level" when there are better ways to spend one's time in relation to the current state of the art.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi,
Member 7989122 wrote: Which software is available to do give me that?
I think maybe OSFMount[^] will do what you need.
I've used it in the past for analyzing malware/rootkits.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi guys,
My main setup is a laptop, but I occasionally go on multi-day hiking trips or so and laptop is too big and it could get destroyed. I am thinking about getting a cheap 10 inch tablet that could make my days more productive.
My question is if are tablets any good for coding? If yes, then should I choose windows or just android? I know about online IDEs, but I might not always have an internet connection. I also own a Kindle reader so I expect more uses from a tablet.
Any advice?
Thanks
|
|
|
|
|
I have a Chuwi Hi12, which is a dual boot Windows 10 / Android tablet.
Android for coding? Not a lot of fun. The keyboard is the main issue - if you use the swipe-to-type then it's predicts the wrong crap all the damn time, if you hunt and peck it still messes you up because it upper-cases and lower-cases at its own whim. So you end up working really slowly because you have to backtrack all the time and fix what you meant to type.
The windows side is OK , mostly - it's nowhere near as fast as a "proper" keyboard if only because it lacks tactile feedback, so if you have taken a touch typing course expect some pain. But ... Visual studio works on it, and not too badly. Slower compilation than my desktop, but you expect that, and most of your time is spent editing code anyway. The latest Windows 10 keyboard is a PITA to an extent - SHIFT, CTRL, and ALT no longer stay on while you hole the key down, so highlighting multiple words is frustrating to say the least.
But yes, you can code on a Windows 10 tablet pretty effectively.
There's a review of the WookieTab here: Take three tablets and call me in the morning - the Chuwi Hi12[^] - the Hi10 is much the same but with a lower display and slower processor IIRC.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Check out the screen of your planned purchase in the day light.
Kindles (e-paper) are intended to work outside; not so much some LCDs.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Add a cheap keyboard.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I originally posted how my Win10 i7, 8GB laptop had crashed and restarted itself here at:
Seriously Win10 What's With the Restart? - The Lounge[^]
@randor had mentioned that I could take a look at the dump file to get more info.
However, at the time the DMP file got delete so I was unable to go further.
My machine rebooted and this time I still have the 997MB DMP file (which is crazy) and I opened it up with WinDbg.
Here's what I see...
I know it's a lot of info but just thought it might be interesting.
You can see that it looks like it is the PCI.sys driver that failed.
Reason I'm Mentioning This
I mention this out of interest and to see if anyone else has had a situation with their Win10 PC rebooting itself like this while not in use.
Just a discussion, not looking for an answer. I know better than to believe we would ever be able to run a cryptic thing like this down. This is the Way of Windows, a magical land where the magic often fails.
DRIVER_POWER_STATE_FAILURE (9f)
A driver has failed to complete a power IRP within a specific time.
Arguments:
Arg1: 0000000000000004, The power transition timed out waiting to synchronize with the Pnp subsystem.
Arg2: 000000000000012c, Timeout in seconds.
Arg3: ffffe680b6184040, The thread currently holding on to the Pnp lock.
Arg4: ffff87012fc7d910, nt!TRIAGE_9F_PNP on Win7 and higher
Debugging Details:
------------------
Implicit thread is now ffffe680`b6184040
KEY_VALUES_STRING: 1
TIMELINE_ANALYSIS: 1
DUMP_CLASS: 1
DUMP_QUALIFIER: 401
BUILD_VERSION_STRING: 16299.15.amd64fre.rs3_release.170928-1534
SYSTEM_MANUFACTURER: TOSHIBA
SYSTEM_PRODUCT_NAME: Satellite S55t-B
SYSTEM_SKU: INVALID
SYSTEM_VERSION: PSPRDU-008004
BIOS_VENDOR: INSYDE Corp.
BIOS_VERSION: 1.40
BIOS_DATE: 05/13/2014
BASEBOARD_MANUFACTURER: Type2 - Board Vendor Name1
BASEBOARD_PRODUCT: Type2 - Board Product Name1
BASEBOARD_VERSION: Type2 - Board Version
DUMP_TYPE: 1
BUGCHECK_P1: 4
BUGCHECK_P2: 12c
BUGCHECK_P3: ffffe680b6184040
BUGCHECK_P4: ffff87012fc7d910
DRVPOWERSTATE_SUBCODE: 4
IMAGE_NAME: pci.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 43aeedb9
MODULE_NAME: pci
FAULTING_MODULE: fffff80b9ac70000 pci
CPU_COUNT: 8
CPU_MHZ: 9be
CPU_VENDOR: GenuineIntel
CPU_FAMILY: 6
CPU_MODEL: 3c
CPU_STEPPING: 3
CPU_MICROCODE: 6,3c,3,0 (F,M,S,R) SIG: 1E'00000000 (cache) 1E'00000000 (init)
BLACKBOXBSD: 1 (!blackboxbsd)
BLACKBOXPNP: 1 (!blackboxpnp)
DEFAULT_BUCKET_ID: WIN8_DRIVER_FAULT
BUGCHECK_STR: 0x9F
PROCESS_NAME: System
CURRENT_IRQL: 2
ANALYSIS_SESSION_HOST: MOBISILVER8
ANALYSIS_SESSION_TIME: 03-17-2018 12:04:23.0467
ANALYSIS_VERSION: 10.0.17074.1002 amd64fre
STACK_TEXT:
ffff8701`2fc7d8d8 fffff800`3608fbc4 : 00000000`0000009f 00000000`00000004 00000000`0000012c ffffe680`b6184040 : nt!KeBugCheckEx
ffff8701`2fc7d8e0 fffff800`362c6916 : ffff8701`2fc7db10 ffffd680`92cce180 ffffd680`92cce180 000000e6`7551f100 : nt!PnpBugcheckPowerTimeout+0x60
ffff8701`2fc7d940 fffff800`35f58923 : ffffd680`92cce180 00000000`00000000 ffff8701`2fc7db18 00000000`00000000 : nt!PopBuildDeviceNotifyListWatchdog+0x16
ffff8701`2fc7d970 fffff800`35f599bd : 00000000`00000018 00000000`00000000 00000000`00252ac4 ffffd680`92cce180 : nt!KiProcessExpiredTimerList+0x153
ffff8701`2fc7da60 fffff800`3600cdfa : 00000000`00000001 ffffd680`92cce180 00000000`00000000 ffffd680`92cdc200 : nt!KiRetireDpcList+0x43d
ffff8701`2fc7dc60 00000000`00000000 : ffff8701`2fc7e000 ffff8701`2fc78000 00000000`00000000 00000000`00000000 : nt!KiIdleLoop+0x5a
FOLLOWUP_NAME: MachineOwner
IMAGE_VERSION: 10.0.16299.251
STACK_COMMAND: .thread ; .cxr ; kb
FAILURE_BUCKET_ID: 0x9F_4_Netwbw02_IMAGE_pci.sys
BUCKET_ID: 0x9F_4_Netwbw02_IMAGE_pci.sys
PRIMARY_PROBLEM_CLASS: 0x9F_4_Netwbw02_IMAGE_pci.sys
TARGET_TIME: 2018-03-15T05:11:51.000Z
OSBUILD: 16299
OSSERVICEPACK: 0
SERVICEPACK_NUMBER: 0
OS_REVISION: 0
SUITE_MASK: 784
PRODUCT_TYPE: 1
OSPLATFORM_TYPE: x64
OSNAME: Windows 10
OSEDITION: Windows 10 WinNt TerminalServer SingleUserTS Personal
OS_LOCALE:
USER_LCID: 0
OSBUILD_TIMESTAMP: 2018-03-01 00:36:55
BUILDDATESTAMP_STR: 170928-1534
BUILDLAB_STR: rs3_release
BUILDOSVER_STR: 10.0.16299.15.amd64fre.rs3_release.170928-1534
ANALYSIS_SESSION_ELAPSED_TIME: 620
ANALYSIS_SOURCE: KM
FAILURE_ID_HASH_STRING: km:0x9f_4_netwbw02_image_pci.sys
FAILURE_ID_HASH: {6709efd6-2555-4107-d407-a72ec07f114d}
Followup: MachineOwner
|
|
|
|
|
You can set windbg to use microsoft public symbols by specifying
srv*c:\Mylocalfolder*http://msdl.microsoft.com/download/symbols
In the symbols dialog. This helps a lot with reading the stack.
You can run !analyze -v in windbg command window (at the bottom) which will run a basic diagnostic.
So, the bug itself happens when a PC does a power transition, so awake to suspend, awake to sleep, or awake to powered off, or vice versa. ( This is the only time windows sends power IRPs (IO request packet) to the driver stacks.)
Is this what happened?
If not then the dump file you have relates to the restart after the first crash. And the size is normal, it is the entire memory written to file.
The system always overwrites memory.dmp with a new one if it crashes. However you can also get it to write a minidump. (system advanced start up and recovery). These files are much smaller, arent as useful of course, but are time stamped.
But, I would be very surprised if pci.sys held on to a power IRP, so it is either a false positive, or some other driver in the stack thats making pci.sys f*** up.
This is where the fun starts. Verifier.exe is a tool that can monitor drivers for bad behaviour. It can only manage two or three at a time. SO run it, select custom settings, select all the checks except code integrity, VM and low resource, and then select two or three non microsoft drivers.
Hopefully verifier will point out the bad driver and you can get rid of it, or try to find an update. (And there are many bad third party drivers out there. A heck of a lot)
The reason you often get false positives is that one driver can overwrite anothers memory. When the second driver runs, can be many hours later, it does something wrong because it is now using bad data, or a bad address, and it fails. But it isnt at fault, it is the first driver.
|
|
|
|
|
I will take a close look at each thing you mentioned and see what I get.
Thanks,
|
|
|
|
|
In cases like this, I clear all the logs and just wait for a pattern between work habits and events.
(Deleting / disabling a lot of redundant apps / services / task scheduler tasks in the process).
Solved a lot of issues in one case by not using the machine vendor's "program launcher".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
|
It's spam: the site he's linked to has the same name as the company listed on his profile.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I'm finally taking the plunge into the hardware world, and found the well written tutorial here on CodeProject.com, FMBomb - A Beginner's Approach to Hardware Programming. Unfortunately, I have not been able to find the NS73M breakout board for sale anywhere. It seems to have been discontinued. Can anyone recommend an alternative board that would work for that project?
EDIT: I stumbled upon this board. Anyone know if this board would be suitable?
SparkFun RFM69 Breakout (915MHz):
[LINK DELETED]
|
|
|
|
|
This came up a potential abuse, but I think it's innocent in this case. I've removed your link, because it looks very spammy - and if left, you would probably be tagged as a spammer very quickly, and banned from the site.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You could ask the person who wrote the article.
|
|
|
|
|
I have the Alexa app on my IPad, Sony Bravia TV with Alexa setup app, and Echo Dot. I follow all the steps to setup. When I attempt to link Google & Amazon accounts via the Bravia TV Remote app it fails and I get an error screen. Everything seems to be in order. I tried whatever I could find with a search without success. I appreciate any help or good reference to get them connected.
|
|
|
|
|
Hi All,
I have a problem in installing Internet Printer programmatically with username and password.
I am able to install Printer using the following command:
rundll32 printui.dll,PrintUIEntry /if /b "Printername" /f %windir%\inf\ntprint.inf /r "https://username:password@devl-ipp.com/printers/Printername"; /m "HP Color LaserJet 2500 PS Class Driver"
But Windows is not recognizing credentials. Hence I cant Print. I get Access denied message.
Is there any option to achieve this programmatically?
Any help will be greatly appreciated.
Regards
Mathew
|
|
|
|
|