I have just started with Arduino but have a lengthy history with micro-controllers. I am working on a project to communicate with an automotive PCM at 8192 baud. My code is working BUT I would like to modify the library in a slight way. Instead of driving high/low I would like to make my tx output multidrop (pulls low only).
I downloaded what I thought was the library but after looking through it, believe it isn't the same code. Where can I find the library code that is used when I define
#include <SoftwareSerial.h>
The code I have is table driven to a number of regular modem baud rates. I need things like 1887 and 8192. Platform I am using is 1.8.13. Processor is ATMega328P. Board is "nano".
SoftwareSerial is one of the built in libraries for the Arduino Nano so there is no need to download it. Have a look in C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\
@UKHeliBob is correct, but there is one other thing you should be aware of when you are modifying these "platform bundled" libraries: the copy of the Arduino AVR Boards platform bundled with the Arduino IDE (C:\Program Files (x86)\Arduino\hardware\arduino\avr if you used the default path of the Windows installer) will no longer be used if you update Arduino AVR Boards via the Arduino IDE Boards Manager. The reason is that Boards Manager installs platforms to a different location on your computer.
It can be very confusing if you're making modifications to the copy of the library that isn't being used by the compiler.
If you enable "Verbose output during: compilation" in File > Preferences, compile a sketch that uses the library, then check the contents of the black console pane at the bottom of the Arduino IDE window, you will find the paths of the libraries that were used. You can also jump right to the folder containing the library in use by opening one of its example sketches from the File > Examples > SoftwareSerial menu, then doing Sketch > Show sketch folder. That opens the example sketch folder, which is in a subfolder of the library, so you'll need to navigate up a couple folder levels to get to the library root folder.
Yeah, there are periodic updates to the Arduino AVR Boards platform and the IDE will give you a notification prompting you to update. When you do that update, the previous Boards Manager installation will be removed and any customized files in that location lost. In the case of modifying the copy in the Arduino IDE installation folder, the modified files will be lost when you update to a new version of the IDE.
The normal approach is to do library development on a copy of the library in the "libraries" subfolder of your sketchbook folder (shown in the Arduino IDE's File > Preferences > Sketchbook location preference). The sketchbook folder contents are not affected by boards platform and IDE updates.
However, this is a little bit tricky when dealing with libraries like SoftwareSerial that are normally bundled with the boards platform. The reason is that the platform bundled libraries are only accessible when compiling for a board of that platform. This allows each platform to provide its own implementation of these libraries (which are normally very architecture-specific). The APIs of the platform bundled libraries are generally all compatible, so the average user never notices that a different library is used for each board, but the low level implementation of each of those libraries might be very different. The libraries installed to the sketchbook are accessible to every board, so there is a chance that the AVR-specific SoftwareSerial library could end up being used when compiling for another board its not compatible with. The Arduino IDE does have a system for automatically picking the right library when there are multiple possible options (all the boring details here if you're interested), and will also show a message in the console that multiple libraries werefound, so in practice this is probably not a problem, but if you do that it is good to take a mental note in case you start having some strange results at some time in the future.
I believe RS485 is a differential standard. It could be used, one phase ignored on the output and one phase defaulted on the in side.
I think that I am good now... just getting used to some of the specifics of the tools.
pert:
However, this is a little bit tricky when dealing with libraries like SoftwareSerial that are normally bundled with the boards platform. The reason is that the platform bundled libraries are only accessible when compiling for a board of that platform. This allows each platform to provide its own implementation of these libraries (which are normally very architecture-specific). The APIs of the platform bundled libraries are generally all compatible, so the average user never notices that a different library is used for each board, but the low level implementation of each of those libraries might be very different. The libraries installed to the sketchbook are accessible to every board, so there is a chance that the AVR-specific SoftwareSerial library could end up being used when compiling for another board its not compatible with. The Arduino IDE does have a system for automatically picking the right library when there are multiple possible options (all the boring details here if you're interested), and will also show a message in the console that multiple libraries werefound, so in practice this is probably not a problem, but if you do that it is good to take a mental note in case you start having some strange results at some time in the future.
Hi,
I have been trying to follow through those "boring details" but as yet have not found the way to correctly compile the code. Following procedure outlined in How to develop or edit an Arduino library? - Arduino Stack Exchange I am still not able to get things back working as when I use the included library. I expect that you are correct in suggesting that this is because of processor dependent code.
I am continuing to work on this and could use a pointer or two on what I am missing.
Cheers, -Tom
I'm happy to look at it, but first I'll need you to provide some details about the behavior you want and the behavior you're seeing instead of the desired behavior so I can understand the problem.
pert:
I'm happy to look at it, but first I'll need you to provide some details about the behavior you want and the behavior you're seeing instead of the desired behavior so I can understand the problem.
Thanks for your help!
I wish to modify the SoftwareSerial library. I had hoped to create a copy, modify it and use the result in my project. The change I wish to make slightly modifies the transmitter output. A normal UART drives the output high until sending data. Once data is sent it drives a start bit (low) then serially each data bit, ending with a stop bit (high). In my case I wish to create a multi drop line. Instead of driving the transmit line high, it tri-states the output making it an input. The data for output will always be low, high bits will disable the drive and low bits will enable it.
In the SoftwareSerial code, the output is always active and the transmitted bits change the output level. With my change, the output will be changed from active to inactive. When active the data will always be low.
My understanding of all the libraries and references in the code is low. I would like to find the way to properly move a copy of the library, rename it (perhaps SoftSerial). I expect this copy to exist in my Sketchbook\libraries\SoftSerial. I have tried this and find that the class isn't recognised.
One final question... is this the correct forum to be posting this question in?
Regards, -Tom
Check the box next to "Show verbose output during: > compilation
Click "OK"
Sketch > Verify/Compile
After the compilation fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
In a forum reply here, click on the reply field.
Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
Press "Ctrl + V". This will paste the compilation output between the code tags.
Move the cursor outside of the code tags before you add any additional text to your reply.
If the length of the output exceeds the forum's 9000 character limit, save it in a .txt file and post it here as an attachment. If you click the "Reply" button you'll see the "Attachments and other options" link that will allow you to make the attachment.
aldl_interface:
One final question... is this the correct forum to be posting this question in?
pert:
However, this is a little bit tricky when dealing with libraries like SoftwareSerial that are normally bundled with the boards platform.
Just thinking out loud ...
As you have to #include SoftwareSerial I presume you could take a copy of the code and give if a completely different name and either include that in your libraries folder or (IMHO, better still) include it alongside the project code.
That way any updates by the library manager would not have any impact on the revised and renamed code.
Robin2:
any updates by the library manager would have any impact on the revised and renamed code.
Platform bundled libraries are distributed with the boards platform via Boards Manager, not Library Manager. So it would be unusual to find one of these libraries in Library Manager. Arduino wouldn't add them there and it's likely any 3rd party trying to add a library of the same name as the platform bundled libraries used in the official Arduino boards platforms would be asked to change it. For example, SoftwareSerial, EEPROM, HID, SPI, and Wire are not in Library Manager.
However, giving the modified library a unique header file name would avoid any chance of it being unintentionally used instead of the platform bundled SoftwareSerial. It sounds like @aldl_interface is already attempting to do this. The only downside is that you would need to adjust the header file name in any code that is using the previous one. For example, there are libraries that use SoftwareSerial.h.
Using library SoftSerial at version 1.0 in folder: C:\Users\Tom\Documents\_Cars\OBDII\Arduino\Programs\libraries\SoftSerial
It looks like your custom library is being picked up just fine and the errors you're getting are resulting from bugs in your code.
My specialty here is helping with the usage of the Arduino development software. There are others on the forum who specialize in helping with programming, so I'll hand you over into their capable hands.
Interesting, I changed nothing in the code except the library it points at. Even using the "example code" it fails.
The class defined int the .h file of the library is not recognized. The errors are all (?) about the class not existing.
The last try I moved the SoftwareSerial library to the \libraries area. Changed the include line and the constructor line. That is it. It seems as if the .h file is not interpreted as such.
Looking through the errors I posted, it becomes clear that some library is not being linked. The code errors are caused because the compiler doesn't know what type uint8_t is. This is for sure due to linkage of libraries. I thought this would be a quick mod, but it is turning into something else. Suggestions?
The type uint8_t is found in my sketch, but not in the copy of the library. Still un-clear to me why a copy of the SoftwareSerial library, copied locally to the sketchbook and re-named doesn't link correctly.
Please post the complete SW_Serial.h file that the compiler is using. It is not the file in your sketch directory and my installation does not have a file of that name
The error would seem to have nothing to do with uint8_t