MoreRSS

site iconThe Practical DeveloperModify

A constructive and inclusive social network for software developers.
Please copy the RSS to your reader, or quickly subscribe to:

Inoreader Feedly Follow Feedbin Local Reader

Rss preview of Blog of The Practical Developer

Differences Between CAN and Modbus

2025-11-11 13:49:10

I. Overview
Our company offers a comprehensive range of devices supporting both Modbus and CAN protocols. However, selecting the right communication protocol for industrial sites or other applications can be challenging for users. This document aims to clarify the differences between CAN and Modbus to help customers choose products tailored to their specific needs. First, let’s briefly introduce these two protocols:
1.1 CAN Bus is a bus-type communication protocol developed by Bosch in the 1980s. It is defined at the physical and data link layers but lacks an inherent application layer, which can be extended via upper-layer protocols such as CANopen, DeviceNet, or J1939. Originally designed for real-time embedded systems like automotive electronics.
1.2 Modbus Protocol is an application-layer protocol developed by Modicon. It operates over various physical layers, including serial communication (Modbus RTU/ASCII) and Ethernet (Modbus TCP). Modbus is widely used for communication between PLCs, frequency converters, meters, and SCADA systems due to its simplicity, openness, and versatility.
1.3 Summary: CAN is a low-level communication protocol, while Modbus is a high-level application protocol.
II. Physical Layer and Topology
2.1 Transmission Medium and Wiring
CAN: Uses twisted-pair cables (CAN_H/CAN_L) with 120 Ω termination resistors required at both ends of the bus.
Modbus RTU: Typically uses twisted-pair cables (RS485), covering up to ~1200 m at lower baud rates, also requiring termination resistors.
Modbus TCP: Runs over standard Ethernet (Cat5/Cat6) and can reuse existing network infrastructure.
2.2 Node Count and Network Topology
CAN: Supports up to ~110 nodes (depending on transceiver load), with all nodes connected in a "peer-to-peer" architecture.
Modbus RTU: RS-485 buses support a maximum of 32 devices per bus (load-dependent), using a master-slave architecture.
Modbus TCP: Node count is limited only by Ethernet switch ports and network scale.
III. Data Link Layer and Access Mechanisms
3.1 Bus Access Control
CAN: Implements CSMA/CR (Carrier Sense Multiple Access with Collision Resolution) at the bit level. Arbitration is based on message identifiers (IDs), where lower IDs have higher priority, ensuring deterministic access.
Modbus: All communication is initiated by the master station, which polls slaves sequentially. Communication latency depends on polling intervals and the number of devices.
3.2 Error Detection and Handling
CAN: Hardware-level CRC checks, bit-stuffing validation, acknowledgment slots, and automatic retransmission ensure frame integrity and reliability.
Modbus: RTU mode uses CRC-16, while ASCII mode uses LRC. Error timeout and retry logic must be implemented by application software/firmware.
IV. Frame Structure and Payload
4.1 CAN Frame
Identifier and Priority: Standard frames use 11-bit IDs, extended frames use 29-bit IDs, with arbitration based on ascending ID values.
Payload: Classical CAN supports up to 8 bytes; CAN FD supports up to 64 bytes.
4.2 Modbus Frame
Address and Function Code: 1-byte device address + 1-byte function code + data + 2-byte CRC (RTU mode).
Payload Length: Up to 252 bytes in RTU mode; Modbus TCP payload is "unlimited" in practice (constrained by Ethernet packet size).
V. Trade-off Between Speed and Distance
CAN: Maximum speed of 1 Mbps (≤40 m); speed decreases with distance (e.g., 125 kbps at 500 m).
Modbus RTU: Typical baud rates range from 9600–115200 bps; up to ~1200 m at ≤100 kbps.
Modbus TCP: Supports 100 Mbps or 1 Gbps, limited by Ethernet hardware.
VI. Typical Applications
CAN: Automotive internal networks, multi-axis robots, medical devices, and other scenarios requiring deterministic control.
Modbus: PLC-I/O communication, SCADA telemetry, energy management, and building automation.
Our company offers a complete lineup of Modbus and CAN devices:
CAN Series: ECAN series (e.g., ECAN-E01, ECAN-W01, ECAN-S01).
Modbus Series: Remote I/O modules, distributed I/O modules, MA01 serial I/O modules, and ME31 temperature acquisition modules.

🗑️ Add Dynamic Delete Button and Add Row Feature in Joget Spreadsheet

2025-11-11 13:44:52

🧩 Overview

In Joget, the Spreadsheet form element (powered by Handsontable) is perfect for managing tabular data inside forms.
However, it doesn’t natively provide built-in row-level delete buttons or a convenient add row feature.

In this guide, we’ll learn how to:
✅ Add a delete button to each row in a Joget Spreadsheet.
✅ Create a separate “Add Row” button that dynamically inserts new rows.
✅ Keep the entire implementation simple, secure, and fully functional.

⚙️ How It Works

💡 The approach uses a custom column renderer and a jQuery button event:

  • The custom renderer injects a Delete button in a column cell.
  • The button calls hot.alter("remove_row", row) to delete that row.
  • A separate Add Row button triggers hot.alter("insert_row_below") to insert a new row at the bottom.
  • Both actions are performed dynamically without reloading the form.

🧠 Important:

  • Set the spreadsheet column format type to Custom.
  • Paste the renderer script directly in the custom field configuration.
  • Avoid adding any extra comments inside the renderer function (to prevent Joget parser issues).

💻 Full Code

<!-- 🔹 Place this inside your Spreadsheet column (Format Type: Custom) -->
{ { 
  renderer: function (instance, td, row, col, prop, value, cellProperties) { 
    td.innerHTML = "<button type='button' class='eaction'>#i18n.ocs_delete_btn#</button>"; 
    td.style.textAlign = "center"; 
    $(document).ready(function () { 
      let hot = FormUtil.getField("appointments_spreadSheet").data("hot"); 
      let btn = td.querySelector(".eaction"); 
      btn.onclick = function (e) { 
        e.preventDefault(); 
        e.stopPropagation(); 
        hot.alter("remove_row", row); 
      }; 
    }); 
  } 
} }
// 🔹 Add this script in a Custom HTML element below your Spreadsheet

$("#addRowBtn").on("click", function(e) {
    e.preventDefault();
    let hot = FormUtil.getField("appointments_spreadSheet").data("hot");
    console.log({hot: hot});
    if (!hot) {
        console.error("Handsontable not initialized");
        return;
    }

    try {
        let lastRow = hot.countRows();
        hot.alter("insert_row_below", lastRow);
    } catch (err) {
        console.error("Failed to add row", err);
    }
});
<!-- 🔹 Add Row Button -->
<button id="addRowBtn" class="btn btn-primary">
  ➕ Add Row
</button>

🧠 Example Use Cases

Employee Shift Planner – Quickly add or remove shift rows.
Project Task Tracker – Manage task entries dynamically.
Material Request Form – Add/remove item rows on demand.
Appointment List – Delete canceled appointments instantly.

🛠️ Customization Tips

💡 To change the delete button label:
Replace

#i18n.ocs_delete_btn#

with plain text (e.g., "Delete" or "Remove").

⚙️ To use a custom Spreadsheet ID:
Update this line:

FormUtil.getField("appointments_spreadSheet")

to match your spreadsheet’s field ID.

🎨 To style buttons:
Apply CSS in a Custom HTML element:

<style>
  .eaction {
    background-color: #e74c3c;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
  }
  #addRowBtn {
    margin-top: 10px;
  }
</style>

🌟 Key Benefits

User-friendly: Adds clear visual controls to manage rows.
⚙️ Lightweight: Uses only jQuery and built-in Joget APIs.
🚀 Instant updates: No form reload needed.
🧩 Reusable: Works in any spreadsheet-based form.
🔧 Customizable: Easily adjust button text, color, or logic.

🔒 Security Note

⚠️ Ensure that delete actions are contextually safe

  • Only use this feature for client-side data entry (not for record deletion in the database).
  • If connected to backend records, validate all deletion logic on the server side before applying changes.

🧭 Final Thoughts

By adding these small enhancements, your Joget Spreadsheet becomes much more interactive and user-friendly.

Mastering Bash Scripting: A Comprehensive Guide for Developers

2025-11-11 13:39:27

Bash scripting is a powerful skill every developer and system administrator should have in their toolkit. Whether you want to automate repetitive tasks, manage system configurations, or streamline your development workflow, Bash scripts can make your life easier.

In this article, we'll dive deep into Bash scripting, explaining what it is, why it's important, and how you can get started writing your own scripts.

What is Bash?

Bash (Bourne Again SHell) is a Unix shell and command language. It’s the default shell on most Linux distributions and macOS. Bash allows users to interact with the operating system via commands, but it also supports scripting — writing sequences of commands saved in a file to automate tasks.

Why Learn Bash Scripting?

  • Automation: Automate repetitive or complex tasks.
  • Efficiency: Save time and reduce human error.
  • System Management: Manage files, users, processes, and networks.
  • Portability: Bash scripts run on nearly any Unix-like system.
  • Integration: Combine with other tools and languages easily.

Bash Scripting Basics

Writing Your First Script

A Bash script is simply a text file containing Bash commands.

#!/bin/bash
echo "Hello, World!"
  • #!/bin/bash — This shebang line tells the system to use Bash to execute the script.
  • echo — Prints text to the terminal.

Save this as hello.sh, give it execute permission, and run it:

chmod +x hello.sh
./hello.sh

Output:

Hello, World!

Common Bash Script Elements

  • Variables
name="Dev.to Reader"
echo "Hello, $name!"
  • User Input
read -p "Enter your name: " user_name
echo "Hello, $user_name!"
  • Conditional Statements
if [ "$name" == "Alice" ]; then
    echo "Welcome Alice!"
else
    echo "You're not Alice."
fi
  • Loops
for i in {1..5}; do
    echo "Number $i"
done

Practical Use Cases

1. Backup Script

Automate backing up important files:

#!/bin/bash
backup_folder=~/backup_$(date +%Y%m%d)
mkdir -p "$backup_folder"
cp -r ~/Documents/* "$backup_folder"
echo "Backup completed at $backup_folder"

2. Monitoring Disk Usage

Alert if disk space is running low:

#!/bin/bash
threshold=80
usage=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')

if [ "$usage" -gt "$threshold" ]; then
    echo "Warning: Disk usage is above $threshold%."
else
    echo "Disk usage is under control."
fi

Debugging Bash Scripts

  • Use bash -x script.sh to run the script in debug mode.
  • Use set -e to exit the script immediately on error.
  • Use set -u to treat unset variables as an error.

Best Practices for Writing Bash Scripts

  • Always use the shebang (#!/bin/bash).
  • Quote variables to prevent word splitting and globbing ("$variable").
  • Use meaningful variable names.
  • Add comments to explain complex parts.
  • Test scripts thoroughly before production use.
  • Handle errors and edge cases gracefully.

Advanced Features

  • Functions
greet() {
    echo "Hello, $1!"
}

greet "World"
  • Command-line Arguments
echo "Script name: $0"
echo "First arg: $1"
echo "Second arg: $2"
  • Using getopts for option parsing
while getopts ":u:p:" opt; do
  case $opt in
    u) username="$OPTARG" ;;
    p) password="$OPTARG" ;;
    \?) echo "Invalid option -$OPTARG" >&2 ;;
  esac
done

Conclusion

Bash scripting is an essential skill for developers and sysadmins alike. It empowers you to automate tasks, manage systems efficiently, and integrate workflows seamlessly.

Start small, experiment with scripts for daily tasks, and gradually explore advanced scripting techniques. The more you practice, the more powerful and productive you’ll become.

Resources to Learn More

Can AI for founders outpace hiring in startups?

2025-11-11 13:29:22

AI for founders: How to build faster, smarter, and cheaper

AI for founders is reshaping how startups build products, test ideas, and raise capital. Because AI lowers the barrier to coding, founders can tinker and ship MVPs faster. As a result, early validation costs less and development cycles shrink.

This shift matters for two reasons. First, practical coding basics plus AI tools let nontechnical founders prototype and iterate without heavy engineering hires. However, understanding when to use AI tools and when to hire remains essential. Moreover, investors now evaluate differentiation beyond models and data.

In this article we explain why knowing to code still matters, even in an AI age. We will cover how AI coding partners change development workflows. We will also explain how to craft defensible moats and how VCs assess category-defining companies. Therefore, founders will get practical steps to build products that scale. Finally, you will learn tactical advice for bootstrappers and hybrid technical founders.

If you are a founder or aspiring founder, this guide helps you decide when to learn to code, when to leverage AI, and how to stand out. Read on to learn practical, investor-ready strategies.

AI empowerment for founders

AI for founders: Practical applications that speed growth

AI for founders powers faster iteration and smarter decision making. Because tools can suggest code and surface patterns, founders move from idea to prototype quickly. For example, AI coding assistants like GitHub Copilot can write boilerplate, explain errors, and speed debugging. As a result, early MVPs ship faster and cost less.

Startups use AI in three core areas. First, product development benefits from automated code suggestions. Second, customer insights improve with AI driven analytics. Third, operations scale using automation for routine tasks. Moreover, teams that adopt these patterns often see outsized growth, as explored in detail at https://articles.emp0.com/ai-first-teams-startups/.

  • Product prototyping with AI coding partners such as https://github.com/features/copilot
  • Data driven customer segmentation that turns signals into product decisions
  • Automated support and onboarding to reduce churn and lower costs

AI for founders: Strategies to build, scale, and defend

Founders must pair AI with strategy to create durable advantage. Therefore, focus on unique data, hard to copy workflows, and distribution channels. Investors now look beyond models alone and value real product hooks. For context on funding dynamics and licensing, see https://articles.emp0.com/ai-licensing-deals-funding-roundup/.

Use these practical tactics today. First, collect first party usage signals that power personalization. Second, automate workflows that reveal customer intent. Third, prototype experiments weekly to validate assumptions. For example, Base44 grew rapidly by iterating quickly and testing features with early users. Also, geographic and market strategy matters beyond Silicon Valley, a point covered at https://articles.emp0.com/entrepreneurship-startup-2025/.

Finally, align hiring with your AI roadmap. Hire people who can instrument product usage. Hire engineers who can ship and monitor AI features. In practice, this approach helps founders build products investors can understand and scale.

Quick comparison of AI tools for founders

Below is a concise table comparing popular AI platforms founders use to prototype, automate, and scale. Each row lists primary function, ease of use, typical cost, and when to choose it. Start with free tiers, then upgrade as your product and metrics justify investment.

Tool Primary function Ease of use Cost Ideal founder use case
GitHub Copilot AI coding assistant that suggests code, fills boilerplate, and helps debug Easy for developers; moderate for nontechnical founders Personal subscription around $10 per month; team plans available Technical founders prototyping MVPs and speeding development
ChatGPT (OpenAI) Conversational AI for ideation, drafting, and quick code snippets Very easy; browser and API access Free tier; ChatGPT Plus about $20 per month; API pay as you go Nontechnical founders generating content, tests, and prompts
Replit Ghostwriter In-editor AI coding assistant with live execution Easy for beginners; integrated IDE Free tier; paid plans start near $10 per month Solo founders who want to build and run prototypes without local setup
Hugging Face Inference Hosted models for custom inference and model hosting Moderate; requires ML knowledge Free tier; usage based billing for production Founders needing specialized models or fine tuning
Zapier Visual automation for connecting apps and workflows Very easy; no code required Free tier; paid plans from around $20 per month Automating onboarding, notifications, and routine ops
Notion AI Content assistant inside Notion for notes and specs Very easy; minimal setup Add on pricing or bundled plans Founders documenting requirements, writing specs, and drafting copy

Costs vary by vendor and usage. Test free tiers first, because they often solve early founder needs.

Evidence and case studies: Real AI wins for founders

Concrete examples show how AI for founders moves the needle. For instance, Base44 grew to more than 100,000 users. By mid‑2025 the company was profitable and was acquired by Wix for roughly $80 million. That outcome shows faster product market fit, because the team iterated rapidly and found early product hooks.

Base44: iterate fast, validate faster

  • What happened: founders shipped small experiments weekly and measured real usage.
  • Tools and tactics: lightweight analytics, rapid prototyping, and user feedback loops. For context on how acquisition paths can follow rapid growth, see Wix at https://www.wix.com/.
  • Result: product market fit occurred sooner, which cut marketing burn and sped fundraising.

AI coding partners: reduce friction in development

Today, AI coding assistants like GitHub Copilot help founders move from idea to prototype quickly. For example, AI can write boilerplate, explain errors, and speed debugging. As a result, founders spend less time on repetitive tasks and more time on product design and customer research. Learn more about Copilot at https://github.com/features/copilot.

Small teams, big leverage

  • Example pattern: a solo or two person team uses an AI assistant to bootstrap an MVP.
  • Outcome: lower engineering costs and faster hypothesis testing.
  • Quote: “You don’t have to wait for someone else to validate your idea — you can do it yourself, quickly and with far less overhead.” This sentiment explains why bootstrappers succeed with AI.

When AI produces measurable gains

  • Customer support: AI driven routing and replies cut response time and lowered churn.
  • Acquisition: targeted personalization from small data signals raised conversion rates.
  • Efficiency: automations reduced ops load so teams focused on growth experiments.

What investors notice

VCs now ask for defensible signals beyond model performance. Therefore founders who pair unique first party data with AI features show stronger defensibility. As one investor put it, “Founders who stay ahead of that curve build at the edge of what is possible today.”

These examples prove a simple point. AI for founders does not replace focus or strategy. However, when combined with rapid iteration and strong market reading, AI can accelerate growth and create investor‑ready outcomes.

CONCLUSION

AI for founders is no longer theoretical. Today it shortens feedback loops, cuts development costs, and amplifies go to market efforts. Therefore, founders who learn to code a little and pair that knowledge with AI tools gain a clear advantage. Moreover, investors now reward teams that turn first party signals into product differentiation.

Practical takeaways are simple. First, embrace AI coding partners to prototype faster. Second, instrument product usage to collect unique data. Third, automate repetitive sales and marketing workflows so the team focuses on growth experiments. As a result, your startup moves from idea to scale with less friction.

EMP0 plays a role here as a US based company that builds AI and automation solutions for sales and marketing automation. It provides ready made tools and proprietary AI workflows that help clients multiply revenue. Importantly, EMP0 deploys AI systems securely under client infrastructure so data stays controlled and compliant.

For founders building MVPs or preparing to fundraise, combine focused coding literacy, AI driven product hooks, and automation. Finally, if you want to explore turnkey AI sales and marketing systems, see EMP0 resources: https://emp0.com, https://articles.emp0.com, https://twitter.com/Emp0_com, https://medium.com/@jharilela, https://n8n.io/creators/jay-emp0.

Frequently Asked Questions about AI for founders

Q1: What does AI for founders mean and why should I care?

A1: AI for founders refers to using machine learning and automation to speed product development, refine go to market efforts, and reduce operational overhead. Because AI shortens feedback loops, founders validate ideas faster and cut costs. Therefore, AI matters for founders who need to move from prototype to product quickly.

Q2: Do I need to learn to code to use AI effectively?

A2: No, you do not need to become a senior engineer. However, learning coding basics helps you tinker, test, and stitch early versions. As a result, nontechnical founders still gain an advantage by understanding how AI coding partners work when building an MVP.

Q3: Which tools should founders try first?

A3: Start with accessible tools that match your needs. For prototyping use AI coding partners and in‑editor assistants. For content and prompts use conversational models. For automation use workflow platforms. In practice, bootstrappers often begin with a mix of an AI code assistant, a conversational model, and an automation tool.

Q4: How can AI help build defensibility and scale?

A4: Focus on collecting first party data and building workflows that competitors cannot easily copy. Then, use AI to turn those signals into personalized experiences. As a result, you create product hooks that compound with usage.

Q5: What common mistakes should founders avoid?

A5: Avoid overreliance on generic models, because they introduce automation bias. Also, watch privacy and security when handling user data. Finally, always test AI features with real users, and iterate based on measurable metrics.

Written by the Emp0 Team (emp0.com)

Explore our workflows and automation tools to supercharge your business.

View our GitHub: github.com/Jharilela

Join us on Discord: jym.god

Contact us: [email protected]

Automate your blog distribution across Twitter, Medium, Dev.to, and more with us.

How I learned to “use AI” in 3 baby steps

2025-11-11 13:25:13

In recent conversations, I've heard a lot of anxiety about "AI fluency." Between companies pushing adoption and jobseekers getting interviewed on how they "use AI," coders worry they're falling behind. On the other hand, they’re also uncomfortable drastically changing what works well for them.

If you feel you need to "use AI" but aren't sure how, here’s what I did to go from "intimidated" to "fluent" without getting disrupted.

Step 1: Make it exist in your IDE

Set up Cursor or Copilot and... do nothing special. Ignore the chat for now, only let it suggest completions and docstrings as you type. Sometimes it seems psychic, other times it'll phrase comments more eloquently than you could, and often it's nonsense. Continue going about your usual workflow while occasionally accepting its suggestions.

Congrats! You've taken your first steps towards "AI fluency." At this point, it's really a smarter autocomplete and shouldn't overhaul your existing workflow. I stayed in this stage for about a month.

Edited version of the

Step 2: Try inline editing

You know those tiny snags: awkward syntax, a type error, a small refactor where your intent is too nuanced to find a direct Stack Overflow answer for? Hovering over the red squiggly line or highlighting some lines should make a "quick edit"/ "fix with AI" option appear. Give it a go! Accept if it fixes it and otherwise undo. If you're up for it, edit the default prompt to add context or specific instructions to up your chances at a good edit.

Inline editing demo in Cursor showing a small window above some code with the prompt 'remove all unsued variables' and the secondary text 'Generating...' From the Cursor inline edit docs. Yes 'unused' is misspelled, maybe to show that LLM's are forgiving of them? 😀

Step 3: Use the chat agent

When I posted codebase questions on Slack, coworkers would reply, "here's what I know, but have you also tried asking Cursor? It's pretty good at answering your type of question." That was my sign from the universe to try the chat agent for bigger stuck moments and legacy spelunking. As I interacted with it, I started to build an intuition for what it does and doesn't do well.

What I ask most:

  • Fixing - "My code isn't working. I expect X but it's doing Y. Here's the error log."
  • Explanations - "Help me understand how function X affects rendering. Walk me through concrete examples."

I write to it like a coworker who is helping me, providing all the context on what the problem is and what I've tried so far.

Nonsensical rambles could happen, but often, it will point to the right neighborhood even if it doesn't hand me the final fix. Once in a while, it nails it. I review its edits as if a coworker edited my branch, with about 20% extra caution.

Switching from 'Auto' to the best model and the largest context window my company provides, GPT-5 MAX, led to slower but much better answers. Getting helpful answers more often motivated me to keep experimenting with it.

For a structured course on chat agent skills, I genuinely recommend the free Anthropic AI fluency course (1-2 hours) which emphasizes how to collaborate effectively and ethically with LLM's:

  • Delegation: Thoughtfully deciding what work to do with AI vs. doing yourself
  • Description: Communicating clearly with AI systems
  • Discernment: Evaluating AI outputs and behavior with a critical eye
  • Diligence: Ensuring you interact with AI responsibly

Conclusion

Now that you have a sense of when to leverage autocompletes, quick edits, and the chat agent, you know how to "use AI" at work. Congrats! With these fundamentals, you should have the confidence to lean further into more advanced usages if you're so inclined.

The learning curve is non-zero, but your Stack Overflow, pair programming, and code tracing strategies both transfer directly and mix-and-match with your new skill. Baby steps will get you there. You got this!